This article applies to our Linux Shared Hosting servers, where browser content compression/mod_deflate is enabled.
GZIP Compression (mod_deflate)
It is possible to utilize mod_deflate with your website, however you will need to implement the correct configuration that suits your website - where:
- You may need to implement .htaccess directives to suit your deployment:
- See Sample Rules below.
- You may need to install plugins to utilize mod_deflate:
- See Dynamic Content below.
Implementing the required directives for your scenario are outside our scope, as such you will need to consult the support documentation/forums etc. of the website/installation/plugins to determine how to enable GZIP compression.
Both the .htaccess file and website have to be crafted in such a way to enable GZIP compression.
In the case of Wordpress, Joomla and other CMS, you typically will need to either install a caching plugin - or similar, or enable functions in the installation, to allow for GZIP compression of the Dynamic content.
As an example for Wordpress, the following popular plugins can cater for this:
- WP Super Cache
- W3 Total Cache
Note: Use these plugins at your own risk.
The following .htaccess directives are typical for common static files:
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/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/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 no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
- Testing Dynamic Content may show that GZIP compression is NOT enabled:
- As such, the best way to test these directives is to check against a static file e.g. a html file.
- For example: domain.tld/readme.html
- Note: You will need to create the file, if it does not exist.
- If you find that the directives enable GZIP for static files, but not Dynamic Content, then you will need to add additional directives/plugins etc. to allow for this.
- .htaccess directives apply from the top folder down i.e.
- If you place the directives in the httpdocs, they will apply to all locations under that folder.
- However, you can potentially override them in .htaccess files below that location.
If you require further assistance with this, please email firstname.lastname@example.org with a brief explanation of the issue and examples/errors which can help replicate the issue.