I am trying to set up mod_deflate to deliver compressed css/js/html content, but am having difficulty getting apache to send the 'content-encoding' header correctly.
I have tried the following, placed in my .htaccess file in the web root:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/javascript text/javascript text/css application/xml
but, checking the headers using firebug, it doesn't appear to be working, even though it does on 开发者_JAVA百科my local copy of MAMP.
Any ideas?
Which version of Apache are you using on your delivery server? I believe the AddOutputFilterByType
is deprecated in versions > 2.1. However, you can still accomplish this, just a few more lines:
SetOutputFilter DEFLATE
SetEnvIf Request_URI "^" no-gzip
SetEnvIf Request_URI \.(?:css|js|html)$ !no-gzip
The DEFLATE
filter, has a built-in check of the no-gzip
environment variable. So, this is turning on the DEFLATE
filter, then turning it off for everything, then turning it back on for css|js|html
files by un-setting the no-gzip
filter for those requests.
Hope that helps.
精彩评论