如何使用gzip设置Content-Encoding [英] How to set Content-Encoding with gzip

查看:3267
本文介绍了如何使用gzip设置Content-Encoding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用gzip压缩html文件。

当我请求index.html时,浏览器(FF 3.0.10)不解压缩或显示index.html.gz(在服务器上预压缩)

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

我在哪里可以确认压缩标题content-encoding和浏览器Accept-Encoding?
(我在C中使用zlib API进行压缩)

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

谢谢。

推荐答案

如果浏览器发送

Accept-Encoding: gzip

您可以压缩http响应的内容,而不是服务器文件系统上的文件。然后在您的HTTP响应中,您必须设置这些标头:

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

这篇关于如何使用gzip设置Content-Encoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆