Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Content-Encoding with gzip

I am compressing html files with gzip.
The browser (FF 3.0.10) does not decompress or display index.html.gz (pre-compressed on the server) when I request index.html

Where can I confirm the zipped header "content-encoding" and the browsers "Accept-Encoding"? (I am using the zlib API in C for zipping)

Thanks.

like image 616
T.T.T. Avatar asked May 14 '09 16:05

T.T.T.


2 Answers

if the browser sends

Accept-Encoding: gzip

you can compress the content of your http response, not the file on the server's file system. Then in your HTTP response you must set these headers:

Content-Length: totalBytes
Content-Encoding: gzip
like image 75
dfa Avatar answered Nov 15 '22 08:11

dfa


(You should also set Vary: Accept-Encoding in the response, technically, to make it clear to caches that the response will be different depending on this request header.)

like image 23
Sean Owen Avatar answered Nov 15 '22 07:11

Sean Owen