Subscribe to our newsletter to receive all the latest on new products and offers.
Website Compression Techniques
gzip - Precompression Method
Precompression means, that you have to compress the files yourself and upload them to your server. This method uses the mod_rewrite feature of Apache HTTP server. So make sure your provider or web server supports it.
All kind of files are supported by this technique, but it doesn't make any sence to compress e.g. a JPEG file or a RAR archive.
I recommend all kind of files which contain text only like html, css or js. You can compress your files easily by a compression tool like 7-Zip. If you have installed 7-Zip, do a right click on your target file, choose 7-Zip in the context menu, select add to archive and compress your file with gzip as archive format. Your archive should have the same name as the uncompressed file plus a ".gz" suffix (e.g. "style.css.gz"). Upload the archive to the same position as the uncompressed file on your server.
Now insert the following code at the end of your .htaccess file:
AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
This code checks if there is an alternative compressed gz-archive with the same name in the same folder available and redirects it to your browser. If the target browser does not support GZIP-compression, it will recieve the uncompressed file.
Verify that mod_rewrite was enabled before. So the following command should exist before the upper one:
Options +FollowSymlinks
RewriteEngine On
You can check the compression of HTML, JavaScript and CSS content on http://analyze.websiteoptimization.com
A big advantage of this technique is, that your server has no loss in performance, because the files are already compressed. So if you don't have to modify your files often, you should give it a try.