我正在使用Apache.
我在我的.htaccess文件中使用以下指令动态地自动gzipping我的HTML和CSS文件.
# Enable ETag FileETag MTime Size # Set expiration header ExpiresActive on ExpiresDefault "access plus 1 year" ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType text/css A2592000 ExpiresByType text/javascript A2592000 ExpiresByType text/js A2592000 # Compress some text file types AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript text/javascript text/js # Deactivate compression for buggy browsers BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
但是,当我使用Firefox的Firebug插件时,我注意到我的javascript文件没有被gzip压缩(只有我的HTML和CSS文件).
任何想法为什么我的JavaScript文件没有被Apache动态gzip压缩?
我想通了,看起来我需要它:
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript
获取javascript压缩/ gzip