I have .htaccess with following code
AddType text/javascript .js
AddOutputFilterByType DEFLATE application/javascript text/javascript application/x-javascript
But Google PageSpeed Insights still telling me, that all of my .js?ver= files is not compressed. I have checked this files with firebug and yes, content-type is "application/javascript", but compression is not working. However, gzip work for css/text/etc.
Help me find out, please.
You could try something like this, assuming mod_headers
is enabled:
<IfModule mod_headers.c>
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz)$">
Header set Content-Encoding gzip
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.