GZIP Compression (mod_deflate)

To use mod_deflate with your website, 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 use mod_deflate:
    • See Dynamic Content below.

 

IMPORTANT NOTE:

You will need to consult the support documentation/forums/blogs etc. for your website/installation/plugins to determine how to enable GZIP compression or call pinguisweb on 087 7547-098.

 


 

Dynamic Content

The .htaccess file and website have to be 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 be used for this:

  • WP Super Cache
  • W3 Total Cache

 


 

Sample Rules

The following .htaccess codes are used in common WordPress files:

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
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

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>

 

Notes:

  • 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.
  • To test your website compression visit https://www.giftofspeed.com/gzip-test/
  • .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.