{"id":819,"date":"2020-06-14T11:08:34","date_gmt":"2020-06-14T18:08:34","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=819"},"modified":"2020-06-14T13:56:08","modified_gmt":"2020-06-14T20:56:08","slug":"how-to-enable-gzip-compression-in-apache","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=819","title":{"rendered":"HOW TO ENABLE GZIP COMPRESSION IN APACHE"},"content":{"rendered":"\n<p>by: <a href=\"https:\/\/knackforge.com\/blog\/karalmax\">Karal Max<\/a>&nbsp;<\/p>\n\n\n\n<p>The mod_deflate module provides the DEFLATE output filter that allows the output from your server to be compressed before being sent to the client over the network. mod_deflate is the replacement of mod_gzip which was used with an older version of Apache.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">ENABLE GZIP MODULE IN APACHE<\/h4>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;By default, a mod_deflate module&nbsp;is enabled in Apache. To make sure that it is enabled,&nbsp;check following line in Apache configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LoadModule deflate_module modules\/mod_deflate.so<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">CONFIGURE GZIP COMPRESSION<\/h4>\n\n\n\n<p>&nbsp; &nbsp; &nbsp;&nbsp;Now edit your apache configuration and add the extensions you want to compress.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/httpd\/conf\/httpd.conf<\/code><\/pre>\n\n\n\n<p>Add the following lines at end of the file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AddOutputFilterByType DEFLATE text\/plain\nAddOutputFilterByType DEFLATE text\/html\nAddOutputFilterByType DEFLATE text\/xml\nAddOutputFilterByType DEFLATE text\/css\nAddOutputFilterByType DEFLATE application\/xml\nAddOutputFilterByType DEFLATE application\/xhtml+xml\nAddOutputFilterByType DEFLATE application\/rss+xml\nAddOutputFilterByType DEFLATE application\/javascript\nAddOutputFilterByType DEFLATE application\/x-javascript<\/code><\/pre>\n\n\n\n<p>Restart Apache service,<\/p>\n\n\n\n<p>## CentOS ##<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service httpd restart<\/code><\/pre>\n\n\n\n<p>## Ubuntu ##<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo \/etc\/init.d\/apache2 restart<\/code><\/pre>\n\n\n\n<p>Add the following configuration in Apache Virtual Host to enable gzip compression for your website. You can also add this code in website&#8217;s .htaccess file in the site root.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \/var\/www\/html\/>\n   &lt;IfModule mod_mime.c>\n\tAddType application\/x-javascript .js\n\tAddType text\/css .css\n   &lt;\/IfModule>\n   &lt;IfModule mod_deflate.c>\n\tAddOutputFilterByType DEFLATE text\/css application\/x-javascript text\/x-component text\/html text\/plain text\/xml application\/javascript\n\t&lt;IfModule mod_setenvif.c>\n\t\tBrowserMatch ^Mozilla\/4 gzip-only-text\/html\n\t\tBrowserMatch ^Mozilla\/4.0&#91;678] no-gzip\n\t\tBrowserMatch bMSIE !no-gzip !gzip-only-text\/html\n\t&lt;\/IfModule>\n    &lt;\/IfModule>\n    Header append Vary User-Agent env=!dont-vary\n&lt;\/Directory>\n<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">TESTING COMPRESSION<\/h5>\n\n\n\n<p>We have enabled gzip compression, let\u2019s use one of below online tools to verify gzip is working correctly.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.giftofspeed.com\/gzip-test\/\">https:\/\/www.giftofspeed.com\/gzip-test\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.whatsmyip.org\/http-compression-test\/\">https:\/\/www.whatsmyip.org\/http-compression-test\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>by: Karal Max&nbsp; The mod_deflate module provides the DEFLATE output filter that allows the output from your server to be compressed before being sent to the client over the network. mod_deflate is the replacement of mod_gzip which was used with an older version of Apache. ENABLE GZIP MODULE IN APACHE &nbsp; &nbsp; &nbsp; &nbsp;By default, <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=819\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[104,5],"tags":[127,126],"class_list":["post-819","post","type-post","status-publish","format-standard","hentry","category-apache","category-linux","tag-apache","tag-gzip"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=819"}],"version-history":[{"count":0,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}