Enable GZIP compression for your website
- 29 March 2017
- 14:36:18
- 2003 views
To speed up your website, it is possible to enable Gzip-compression. By default it is not turned on, because it could cause problems, but in most cases you can enable without any worries.
Enabling Gzip compression is very easy. You can test if it works well for your website, and easily turn it off again if it causes problems.
Create a new file called .htaccess in the httpdocs folder of your website, containing the lines below. If you already have an existing .htaccess file, you can add these lines to it:
<IfModule mod_deflate.c>
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
</IfModule>
You can check if the compression is enabled correctly by using
https://checkgzipcompression.com/ or
http://www.websiteplanet.com/webtools/gzip-compression/Except that the website will load faster, you can also save on datatraffic. It often saves up to 60-70%!