我在使用 gzip 时遇到了一点问题
YSlow 说:
使用 gzip 压缩组件的 F 级
有 5 个纯文本组件需要压缩发送
页面速度说道:
启用压缩
但它在我的.htaccess中处于活动状态:
这是我的.htaccess
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType "text/javascript" .js.jgz
RewriteRule (.*)\.css$ $1\.css.jgz [L]
AddType "text/css" .css.jgz
AddEncoding gzip .jgz
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
我将 css 和 js 压缩在同一个目录中。
我是这样测试的:我删除了 web 服务器上的浏览器缓存和 style.css。我刷新了我的主页,css 通过 gzip 发送,没有任何问题
还有什么缺失吗?
这只是一个测试账户,域名到周日才可用
Yslow 说:
Grade F on Compress components with gzip
There are 5 plain text components that should be sent compressed
* http://test72544.test-account.com/
* http://test72544.test-account.com/css/style.css
* http://test72544.test-account.com/css/print.css
* http://test72544.test-account.com/js/js/jquery.min.js
* http://test72544.test-account.com/js/js/scripts.js
PageSpeed 说:
Compressing the following resources with gzip could reduce their transfer
size by 51.6KiB (69% reduction).
Compressing http://test72544.test-account.com/js/js/jquery.min.js could save 20.1KiB (62% reduction).
Compressing http://test72544.test-account.com/css/style.css could save 14.5KiB (79% reduction).
Compressing http://test72544.test-account.com/css/print.css could save 7.2KiB (76% reduction).
Compressing http://test72544.test-account.com/ could save 5.0KiB (74% reduction).
Compressing http://test72544.test-account.com/js/js/scripts.js could save 4.8KiB (65% reduction).
我不想使用 mod_deflate,因为我不想对服务器提出过高的要求
答案1
您有我们可以看看的 URL 吗?
YSlow 和 PageSpeed 表示哪些资源未压缩?
另外很好奇为什么你使用 URL 重写而不是 mod_deflate 来解决这个问题(http://httpd.apache.org/docs/2.0/mod/mod_deflate.html)