Speeding Up the Site With Apache GZIP Compression
Posted on In WebWe can speed up the site with compression while save bandwidth at the same time. As most of the modern browsers support gzip encoding, we can set it up to let the users enjoy faster speed. The Apache mod_deflate is easy to set up and standard. It compress the content on the fly.
We can enable output compression in Apache by adding the following into the .htaccess file in the root directory of the website:
# Compress html, text, javascript, css and xml content: 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 text/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/x-javascript
If the .htaccess file can’t be edited or the mode isn’t enabled, there is another alternative solution for php supported environment:
Hi I am using this gzip,
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php)$
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.*
what is the difference with the one you are showing on you blog?
Regards,
Richard.
Hi Richard,
Your method uses the mod_gzip module.
The method in this post uses the mod_deflate module. The method in this post explicitly exclude files by MIME types only.
Both methods should be okay if they works well. For the compression rate, both methods, generate roughly the same one (mod_gzip is slightly better).