下面是我正在为wordpress博客编写的.htaccess文件。
我正在尝试缓存图像、javascript和css文件。当我在Chrome dev工具中查看时,它显示304 not modified,而不是缓存这些文件。我想知道为什么不缓存?有什么想法吗?我被困在共享主机上,因此我必须使用.htaccess文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^assets/css/(.*) /wp-content/themes/codedevelopr/assets/css/$1 [QSA,L]
RewriteRule ^assets/js/(.*) /wp-content/themes/codedevelopr/assets/js/$1 [QSA,L]
RewriteRule ^assets/images/(.*) /wp-content/themes/codedevelopr/assets/images/$1 [QSA,L]
RewriteRule ^assets/fonts/(.*) /wp-content/themes/codedevelopr/assets/fonts/$1 [QSA,L]
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# cache images and flash content for one month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# cache text, css, and javascript files for one week
<FilesMatch ".(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
# explicitly disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
# use utf-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
# force utf-8 for a number of file formats
AddCharset utf-8 .html .css .js .xml .json .rss发布于 2012-02-28 14:11:58
304 not modified是当您发送一个有条件的GET请求时服务器回复的内容,在报头中带有Etag或if-modified- send杂注。
服务器将只回复该报头,而不包括任何响应正文。
所以,是的,你的Chrome实际上是在兑现请求。
https://stackoverflow.com/questions/9477231
复制相似问题