Ste*_*son 3 gzip cherrypy yslow
我正在使用Chrome和Firefox下的Yslow工具审查我的开发网站,其中一个建议是我gzip适当的内容.作为起点,我刚刚将"tools.gzip.on = True"添加到我的[/]配置中.我知道配置文件和块正在被正确解析,因为我还在响应头中添加了禁用缓存的选项,因为我在开发站点时经常更改文件.我在回复中看到"Expires"和"Pragma:no-cache"标题.
出于某种原因,即使在更改配置文件(并重新启动过程,这不是绝对必要的)之后,Yslow仍然报告我没有使用gzip.我也一直在使用wget并且看不到Content-Encoding标头.
任何人都可以建议我如何验证发生了什么?我想知道这个问题是否忽略了gzip设置,或者Yslow只是弄错了事实.我之前从未遇到过Yslow的麻烦,所以我倾向于前者.
我要补充一点,Yslow只报告我的外部CSS和JavaScript文件(由同一个樱桃过程提供服务)需要压缩,即使"wget -S"显示的标题甚至不显示gzip编码页面本身(动态内容).
我尝试将"tools.gzip.on = True"添加到我的[/ css]和[/ js]块中,我也尝试在所有相同的块中设置"tools.encode.on = True",想想也许编码必须启用gzip才能工作.
提前致谢.
cherrypy.lib.gzip的3.2 docstring:
def gzip(compress_level=5, mime_types=['text/html', 'text/plain'], debug=False):
"""Try to gzip the response body if Content-Type in mime_types.
cherrypy.response.headers['Content-Type'] must be set to one of the
values in the mime_types arg before calling this function.
The provided list of mime-types must be of one of the following form:
* type/subtype
* type/*
* type/*+subtype
No compression is performed if any of the following hold:
* The client sends no Accept-Encoding request header
* No 'gzip' or 'x-gzip' is present in the Accept-Encoding header
* No 'gzip' or 'x-gzip' with a qvalue > 0 is present
* The 'identity' value is given with a qvalue > 0.
"""
Run Code Online (Sandbox Code Playgroud)
我的钱是关于MIME类型的,因为你提到了JS和CSS.你可以这样改变:
[/static]
tools.gzip.mime_types: ['text/html', 'text/plain', 'text/javascript', 'text/css']
Run Code Online (Sandbox Code Playgroud)
在CherryPy 3.2+中,您可以将其缩短为:
[/static]
tools.gzip.mime_types: ['text/*']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2767 次 |
| 最近记录: |