Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
What webserver software are you using? Nginx does have a pre-gzip module, but I'm guessing you're using Wordpress/Apache or something. – Cyclops Sep 25 '11 at 13:06
Did any of the below answers help? – Fiasco Labs Oct 17 '11 at 22:59
up vote 2 down vote accepted

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]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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