How to enable Gzip to speed up your website

Navigate to the www directory of your website.

Open or create a .htaccess file.


Copy the following code into it


AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


If that does not work, try the following in its place. You may test this configuration using Google - https://developers.google.com/speed/pagespeed/insights/?


<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How to use your .htaccess file to minify your CSS / Javascript

<IfModule mod_rewrite.c>RewriteEngine on # You may need RewriteBase on some...

Remove mod_pagespeed (a caching module enabled by default)

Our servers use mod_pagespeed by default.This is an open source module which compresses pages...

How to install Django on shared cPanel hosting

- Log into your account using SSH. - pip install django==1.8.7- pip install flup==1.0.2 - cd ~...