我想我的javascript和css文件的gzip压缩,但对于CSS不起作用

我正在尝试gzip压缩为我的js和css文件。 但对于CSS它不工作。 另外当我做页面速度分析使用Firefox的页面速度,它要求在您的服务器上启用gzip压缩。 这意味着gzip压缩不起作用。

这里是我在每个PHP文件的顶部使用的PHP代码

if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); 

这里是用于gzip压缩的.htaccess代码

 <IfModule mod_deflate.c> # Insert filter on all content ###SetOutputFilter DEFLATE # Insert filter on selected content types only AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript # 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 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE image/png AddOutputFilterByType DEFLATE image/gif AddOutputFilterByType DEFLATE image/jpg AddOutputFilterByType DEFLATE image/jpeg AddOutputFilterByType DEFLATE image/vnd.microsoft.icon AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript # Or, compress certain file types by extension: <Files *.html> SetOutputFilter DEFLATE </Files> 

谁能帮我? 我的网站url是http://www.pricecatalogs.com/

你确定CSS文件的MIMEtypes正在设置吗?

 AddType text/css .css 

在你的HTML中,当你包含css文件时你应该​​有type =“text / css”:
<link type="text/" href="style.css" ... />