{"id":100,"date":"2023-05-01T05:50:16","date_gmt":"2023-05-01T05:50:16","guid":{"rendered":"https:\/\/www.cmsgalaxy.com\/blog\/?p=100"},"modified":"2023-05-01T05:50:16","modified_gmt":"2023-05-01T05:50:16","slug":"how-to-setup-caching-gzip-compression-in-apache-web-server-with-htaccess","status":"publish","type":"post","link":"https:\/\/www.cmsgalaxy.com\/blog\/how-to-setup-caching-gzip-compression-in-apache-web-server-with-htaccess\/","title":{"rendered":"How to setup caching &amp; GZIP compression in Apache Web Server with .htaccess"},"content":{"rendered":"\n<p>To setup caching and GZIP compression in Apache Web Server with .htaccess, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Enable mod_deflate: First, you need to enable the mod_deflate module in your Apache web server. You can do this by adding the following line to your Apache configuration file (httpd.conf):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>LoadModule deflate_module modules\/mod_deflate.so\r\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create .htaccess file: Next, create a new file named .htaccess in the root directory of your website.<\/li>\n\n\n\n<li>Enable GZIP compression: Add the following lines to your .htaccess file to enable GZIP compression:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Enable GZIP compression\r\n&lt;IfModule mod_deflate.c>\r\nAddOutputFilterByType DEFLATE text\/plain\r\nAddOutputFilterByType DEFLATE text\/html\r\nAddOutputFilterByType DEFLATE text\/xml\r\nAddOutputFilterByType DEFLATE text\/css\r\nAddOutputFilterByType DEFLATE application\/xml\r\nAddOutputFilterByType DEFLATE application\/xhtml+xml\r\nAddOutputFilterByType DEFLATE application\/rss+xml\r\nAddOutputFilterByType DEFLATE application\/javascript\r\nAddOutputFilterByType DEFLATE application\/x-javascript\r\n&lt;\/IfModule>\r\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>hese lines will tell Apache to compress the specified file types before sending them to the user&#8217;s browser.<\/li>\n\n\n\n<li>Set caching rules: Add the following lines to your .htaccess file to set caching rules:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Set caching rules\r\n&lt;IfModule mod_headers.c>\r\n&lt;FilesMatch \"\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$\">\r\nHeader set Cache-Control \"max-age=86400, public\"\r\n&lt;\/FilesMatch>\r\n&lt;\/IfModule>\r\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>These lines will set caching rules for the specified file types. The &#8220;max-age&#8221; value tells the browser to cache the files for a certain amount of time (in seconds).<\/li>\n\n\n\n<li>Save the .htaccess file: Save the changes to your .htaccess file and upload it to the root directory of your website.<\/li>\n\n\n\n<li>Test your website: Test your website using Google PageSpeed Insights or other similar tools to verify that GZIP compression and caching are working properly.<\/li>\n<\/ol>\n\n\n\n<p>Note: These steps assume that you have access to the Apache configuration file and the ability to enable modules. If you are on a shared hosting plan, you may not have access to these settings and will need to contact your hosting provider for assistance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To setup caching and GZIP compression in Apache Web Server with .htaccess, follow these steps: Note: These steps assume that<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":1,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":101,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions\/101"}],"wp:attachment":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}