我正在使用 YSlow 来提高我网站的速度,但我在“使用 gzip 压缩组件”等级方面遇到了麻烦。我的 .htaccess 文件中有这个:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
但是 YSlow 说
There are 4 plain text components that should be sent compressed
* http://crewinyourcode.com/css/reset.css
* http://crewinyourcode.com/css/inner-pages/index.css
* http://crewinyourcode.com/script/css/jquery-ui-1.8.custom.css
* http://crewinyourcode.com/js/inner-pages/index.js
如何压缩 css 和 js 文件?
另外...我无权访问 httpd.conf 文件。
您可以在 http://crewinyourcode.com 查看问题
更新:
已添加
AddType text/css .css
AddType application/x-javascript .js
到 .htaccess,它似乎没有帮助。
最佳答案
你有 .css 和 .js 的 AddType 行吗? Apache 很难仅通过内容自动找出类型——它们看起来很像 C 代码。
尝试将这些行添加到您的 .htaccess...
AddType text/css .css
AddType application/x-javascript .js
关于javascript - GZipping CSS 和 JS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2795493/