首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不修改304是否等同于缓存资源?

不修改304是否等同于缓存资源?
EN

Stack Overflow用户
提问于 2012-02-28 14:09:07
回答 1查看 1.7K关注 0票数 1

下面是我正在为wordpress博客编写的.htaccess文件。

我正在尝试缓存图像、javascript和css文件。当我在Chrome dev工具中查看时,它显示304 not modified,而不是缓存这些文件。我想知道为什么不缓存?有什么想法吗?我被困在共享主机上,因此我必须使用.htaccess文件

代码语言:javascript
运行
复制
# 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-28 14:11:58

304 not modified是当您发送一个有条件的GET请求时服务器回复的内容,在报头中带有Etag或if-modified- send杂注。

服务器将只回复该报头,而不包括任何响应正文。

所以,是的,你的Chrome实际上是在兑现请求。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9477231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档