无论我如何使用不同的Accept-Encoding值进行testing,它总是以gzip的forms返回。 curl -I -H 'Accept-Encoding: gzip' http://www.example.com Content-Encoding: gzip curl -I -H 'Accept-Encoding: deflate' http://www.example.com Content-Encoding: gzip 那么如何强制放气呢?
我把以下内容放在我的http.conf文件中: # mod_deflate configuration <IfModule mod_deflate.c> # Restrict compression to these MIME types AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/css # Level of compression (Highest 9 – Lowest 1) DeflateCompressionLevel 9 # Netscape 4.x has some problems. BrowserMatch […]
我注意到谷歌网站pipe理员工具有关gzip版本的网站地图的错误。 原来, sitemap.xml.gz文件被压缩了两次:一次创build(应该是),另一次被提供服务。 .htaccess文件有这个规则 AddOutputFilterByType DEFLATE application/xml 我认为这不匹配一个gzipped的XML文件,但显然这是作为解决这个问题。 我究竟做错了什么?
我想知道如果有人在这里可以帮助我确定使用mod deflate与Apache的最佳标准configuration。 基本上,mod_deflatebuild议使用以下configuration立即开始: 只压缩几个types AddOutputFilterByType DEFLATE text / html text / plain text / xml http://httpd.apache.org/docs/2.0/mod/mod_deflate.html 但是,只需阅读文档,就可以为所有浏览器自定义此文档。 另外,你可以为所有不同types的MIMEtypes定制mod_deflate。 我想知道有没有人试过这些设置,并find了一个最适合所有浏览器的设置。 Apache提供的另一个示例,但是如果您不了解所有configuration选项,请提及不要使用: <Location /> # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems… BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine […]
有些CSS和JS文件不是由Apache启用mod_deflate压缩的。 这个文件在YSlow中看起来像这个“[domain.name] /aggregator.css?…”或者“[domain.name] /misc/jquery.js?…”。 另一个没有“?”的CSS&JS 被压缩。 请解释我如何使apache压缩这个文件也。 我在.htaccess文件中添加了以下行 <IfModule mod_deflate.c> <FilesMatch "\.(css|js|x?html?|php)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> 谢谢
如何通过.htaccess启用Gzip或Deflate压缩,以及哪一个最好? 代码示例需要。