304 Not Modified是否与缓存资源相同?

时间:2012-02-28 06:09:07

标签: apache .htaccess

以下是我正在为wordpress博客/

工作的.htaccess文件

我正在尝试缓存图片,javascript和css文件。当我在Chrome开发工具中查看而不是缓存这些文件时,它会显示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

1 个答案:

答案 0 :(得分:2)

304 not modified是服务器在发送条件GET请求时回复的内容,标题中包含Etag或if-modified-since pragmata。

服务器只回复该标题,不包含任何回复正文。

是的,您的Chrome实际上正在兑现请求。