Nik*_*ola 1 apache .htaccess mod-deflate
我.htaccess
直接从html5boilerplate.com复制了以下文件:
<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
Run Code Online (Sandbox Code Playgroud)
YSlow只显示一个未压缩的文件,它的文件名是,testing.cache
而且它的内容是html和css的混合.我将文件重命名为testing.html
,文件被压缩得很好.我期望testing.cache
文件也会被压缩,因为它属于text/html
组(这是我在页面加载时通过ajax加载的文件).所以,我想知道我是否可以这样:
<FilesMatch "\.(cache)$">
someDirectiveToCache .cache file
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
我已经看过任何匹配指令的mod_deflate,但没有运气.当然,我可以把它留下来,testing.html
但我想知道如何做到这一点testing.cache
.此外,我推测FilesMatch
可以在<IfModule mod_deflate.c>
模块中使用,因为它可以(测试和使用它)在<IfModule mod_expires.c>
这样的内部使用:
<FilesMatch "\.(cache)$">
ExpiresDefault "access plus 1 hour"
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
我的Apache版本(如果重要)是:2.2.15.
我设法让这个工作,实际上最终很容易.我浏览了所有文档,找到了AddOutputFilter
简单易用的指令,实际上可以使用扩展.
版本2.2的文档中所述的AddOutputFilter指令语法是:
AddOutputFilter filter[;filter...] extension [extension] ...
Run Code Online (Sandbox Code Playgroud)
在我AddOutputFilterByType
添加指令后的示例中:
AddOutputFilter DEFLATE cache
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助将来的某个人.
归档时间: |
|
查看次数: |
1099 次 |
最近记录: |