Jul 072010
 

http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

Actually I've already got a post about this and other techniques (in German).

Pre-Compressing files

If your files get really big, and never change, it's time to add a new technique to your toolbelt: the pre-compression!

Use 7-zip to GZIP your files in ultimate mode, drop them on your server. Add some .htaccess and PHP magic, like so:

<?PHP
header('Content-Encoding: gzip');
$req = $_SERVER['REQUEST_URI'];
$req_a = explode('/',$req);
readfile($req_a[2] . '.gz');
?>

(assuming your files will be reachable by /xyz/file and are stored with .gz as extension)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /104/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php [L]
</IfModule>

Modify your RewriteBase accordingly!

This will work wonders for huge files with repetetive content – no more processing overhead server-side, all files delivered faster, happy customers … don't forget to write about your ideas and experiences with this!

 Posted by at 7:07 pm