我无法让浏览器缓存JS和CSS文件。 谷歌的PageSpeed工具显示一切都井井有条,但浏览器提供了状态" 200 OK"而不是" 304未修改"对于所有文件JS和CSS。可能是什么错误?
.htaccess代码
Options All -ExecCGI +Indexes +Includes +FollowSymLinks
# HANDLER ___________________
AddHandler application/x-httpd-php .html
AddHandler cgi-script .pl .py .jsp .asp .htm .sh .cgi
AddType application/x-javascript .js
AddType application/json .json
AddType text/css .css
AddType text/xml .xml
AddType text/html .shtml
# Audio
AddType audio/ogg .oga .ogg
AddType audio/mp4 .m4a .f4a .f4b
# Video
AddType video/ogg .ogv
AddType video/mp4 .mp4 .m4v .f4v .f4p
AddType video/webm .webm
AddType video/x-flv .flv
# SVG
AddType image/svg+xml .svg .svgz
AddEncoding gzip .svgz
# Webfonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf .ttc
AddType font/opentype .otf
AddType application/x-font-woff .woff
# Assorted types
AddType image/x-icon .ico
AddType image/webp .webp
AddType text/cache-manifest .appcache .manifest
AddType text/x-component .htc
AddType application/xml .rss .atom .xml .rdf
AddType application/x-chrome-extension .crx
AddType application/x-opera-extension .oex
AddType application/x-xpinstall .xpi
AddType application/octet-stream .safariextz
AddType application/x-web-app-manifest+json .webapp
AddType text/x-vcard .vcf
AddType application/x-shockwave-flash .swf
AddType text/vtt .vtt
AddType application/octet-stream .doc .mov .avi .pdf .xls .rar .zip .mp3 .wmv .ppt .tar .gz .docx .xlsx
# <ifModule mod_expires.c>
# ExpiresActive On
# ExpiresDefault "access plus 5 seconds"
# ExpiresByType image/x-icon "access plus 5 seconds"
# ExpiresByType image/jpeg "access plus 2592000 seconds"
# ExpiresByType image/png "access plus 2592000 seconds"
# ExpiresByType image/gif "access plus 2592000 seconds"
# ExpiresByType video/ogg "access plus 1 month"
# ExpiresByType audio/ogg "access plus 1 month"
# ExpiresByType video/mp4 "access plus 1 month"
# ExpiresByType video/webm "access plus 1 month"
# ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
# ExpiresByType text/css "access plus 604800 seconds"
# ExpiresByType text/javascript "access plus 604800 seconds"
# ExpiresByType application/javascript "access plus 604800 seconds"
# ExpiresByType application/x-javascript "access plus 604800 seconds"
# ExpiresByType text/html "access plus 43200 seconds"
# ExpiresByType application/xhtml+xml "access plus 600 seconds"
# ExpiresByType text/xml "access plus 600 seconds"
# ExpiresByType application/xml "access plus 600 seconds"
# ExpiresByType application/json "access plus 600 seconds"
# ExpiresByType application/rss+xml "access plus 1 hour"
# ExpiresByType application/atom+xml "access plus 1 hour"
# ExpiresByType text/x-component "access plus 1 week"
# ExpiresByType application/x-font-ttf "access plus 1 month"
# ExpiresByType font/opentype "access plus 1 month"
# ExpiresByType application/x-font-woff "access plus 1 month"
# ExpiresByType image/svg+xml "access plus 1 month"
# ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# </ifModule>
<ifModule mod_headers.c>
<FilesMatch "\.(html|htm|shtml)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png|jpe?g)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# PHP
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|lato.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|lato.css)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
<FilesMatch "mijs.js|mistyle.css$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
# 1 день = 86400 секунд
# 1 неделя = 604800 секунд
# 1 месяц = 2629000 секунд
# 1 год = 31536000 секунд