Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
add comment

1 Answer 1

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

http://perfectionlabstips.wordpress.com/2008/12/30/serving-gzipped-gz-files-as-compressed-css-javascript-html-content/

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
add comment

Your Answer

 
discard

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.