Page load time optimization (GZIP and DEFLATE)
Posted by Helpdesk Admin on 04 June 2014 01:44 PM
When optimizing the load time of your web pages, the number and size of files to be transferred is important especially for visitors on slower broadband connections.
It is well known that image files should be optimized before uploading to the web server in order to ensure the page loads as fast as possible.
Such data consists largely of plain text and so is very suitable for compression - it is not unusual to be able to reduce such content by 80 or 90% leading to an improvement in page loading time.
In general, there are two methods used for compressing such data.
For "pure" compressible static content (.js, .css, .html files) you can use Apache's mod_deflate module to do this. The module is already present on all Linux hosting accounts, however you need to enable it via a .htaccess file in the main root directory of the website.
For full information on mod_deflate, please view the information at http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
The following directives placed in the .htaccess file work well for many situations:
Header append Vary User-Agent env=!dont-vary
If your site is using PHP (most do including WordPress, Joomla, Drupal sites etc) then you can enable GZIP compression for the PHP output. This is done by enabling gzip libraries for PHP.
The following directives should be placed in a file named ".user.ini" in the root directory of the site:
zlib.output_compression = On
Please note that it may take a period of time for the above change to take effect because of caching.