Gzip compression through .htaccess not working

前端 未结 3 991
失恋的感觉
失恋的感觉 2020-12-09 18:20

I have been creating a site and checking it\'s speed through gtmetrix.com. I used the following .htaccess file to compress the .js, .css<

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 19:07

    I have not used mod_gzip but here is my .htaccess I use to gzip .js, .css and other files via mod_deflate:

    #Gzip
    
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
    
    #End Gzip
    

    In case you are not already aware of it, Firebug is very useful for checking if downloaded content is gzipped. Click on the "Net" tab in Firebug and then do shift-f5 to get Firefox to reload all the .js and .css files so they show in the Net panel. Click the "+" next to the .js or .css file and click the "Headers" tab. If the response is gzipped you will see "Content-Encoding gzip" in the Response Headers section. I image the IE, Safari, and Chrome equivalents offer the same ability.

    There is one gotcha regarding gzipping .js and .css files on IE6 to watch out for. I think it is only applicable to IE6 SP1 users.

提交回复
热议问题