I understand that we can do some settings in .htaccess to allow gzipping on the fly.

However is there anyway we could do it "not-on-the-fly"?

I have a static file that I wish to serve gzipped, but I do not wish to do the gzipping on the fly (in other words pre-gzipped).

How would we go about doing it?


Won't work with IE6 browsers, but here's how WordPress users do it.


Their examples are for CSS and JavaScript, but it's easily applicable for .html from the samples.

They show you how to detect for browsers that won't work and keep an uncompressed copy and compressed copy side by side so your site will work with unsupportive browsers.

The following rule detects if the browser supports gzip, checks to see if you have a .gz file of the same name as the requested file and serves it instead of the uncompressed file:

RewriteCond %{HTTP:Accept-Encoding} gzip 
RewriteCond %{REQUEST_FILENAME}.gz -f 
RewriteRule ^(.*)$ $1.gz [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.