Thursday, November 23, 2017

Apache - Enable gzip compression with .htaccess

Today I found a simple method to enable gzip compression on your homepage, when you are using Apache webserver. You just have to create a .htaccess file with this code, assuming you have mod_deflate enabled in your Apache config.


<IfModule mod_deflate.c>
<FilesMatch "\\.(js|css|html|xml|jpg|png)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

This code snippet provides gzip compression for all js, css, html, xml, jpg and png files.
Ok. Images are most time already compressed, but I added them as well.
Very simple and very useful. :-)

No comments:

Post a Comment