KnowledgebaseHow can we help you?

How to enable GZip compression in Linux

When a user hits your website a call is made to your server to deliver the requested files. The bigger these files are the longer it's going to take for them to get to your browser and appear on the screen. GZip compresses your webpages and style sheets before sending them over to the browser. This drastically reduces transfer time since the files are much smaller. In terms of cost versus benefit, gzip compression should be near the top of your page speed optimizations if you don't have it setup already.

Here you need access to the .htaccess files.

To enable GZip compression in Linux, Paste the following code in .htaccess file.

<IfModule mod_deflate.c>

  # Compress HTML, CSS, JavaScript, Text, XML and fonts

  AddOutputFilterByType DEFLATE application/javascript

  AddOutputFilterByType DEFLATE application/rss+xml

  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject

  AddOutputFilterByType DEFLATE application/x-font

  AddOutputFilterByType DEFLATE application/x-font-opentype

  AddOutputFilterByType DEFLATE application/x-font-otf

  AddOutputFilterByType DEFLATE application/x-font-truetype

  AddOutputFilterByType DEFLATE application/x-font-ttf

  AddOutputFilterByType DEFLATE application/x-javascript

  AddOutputFilterByType DEFLATE application/xhtml+xml

  AddOutputFilterByType DEFLATE application/xml

  AddOutputFilterByType DEFLATE font/opentype

  AddOutputFilterByType DEFLATE font/otf

  AddOutputFilterByType DEFLATE font/ttf

  AddOutputFilterByType DEFLATE image/svg+xml

  AddOutputFilterByType DEFLATE image/x-icon

  AddOutputFilterByType DEFLATE text/css

  AddOutputFilterByType DEFLATE text/html

  AddOutputFilterByType DEFLATE text/javascript

  AddOutputFilterByType DEFLATE text/plain

  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)

  BrowserMatch ^Mozilla/4 gzip-only-text/html

  BrowserMatch ^Mozilla/4\.0[678] no-gzip

  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  Header append Vary User-Agent

</IfModule>

 

After you've saved your .htaccess file, test your site again to make sure it has been properly compressed.

How to enable GZip compression in Linux

Was this answer helpful?

Also Read



+91 9569505379 (Till Covid -19 Outbreak)
10:00 am to 7:30 pm IST Monday to Saturday
Live Chat, Email and Tickets are available 24/7

HostAdvice Great Uptime Award for Gen X Web Hosting
Gen X Web Hosting Reviews