How to set Content-Encoding with gzip

喜你入骨 提交于 2019-12-12 08:51:27

问题


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.


回答1:


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



回答2:


(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.)



来源:https://stackoverflow.com/questions/864448/how-to-set-content-encoding-with-gzip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!