Test on this url http://getapple.net/phpbb/banners.js
测试这个网址http://getapple.net/phpbb/banners.js
It return 304, File not modified.
它返回304,文件未修改。
I have once enable plugin "mod_expires" and set up js to cache for 1 month.
我曾经启用插件“mod_expires”并设置js缓存1个月。
But now i want to reset the rules. I try to comment this line
但现在我想重置规则。我试着评论这一行
ExpiresByType application/javascript "access 1 month"
ExpiresByType应用程序/ javascript“访问1个月”
and then restart apache.
然后重启apache。
But the file still load from cache. (Response Header return 304 in Chrome Browser)
但该文件仍然从缓存加载。 (Chrome浏览器中的响应标题返回304)
But after i run this
但在我运行之后
curl -I http://getapple.net/phpbb/banners.js
in command line, the result are
在命令行中,结果是
HTTP/1.1 200 OK
Date: Sun, 10 May 2015 14:51:59 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Sun, 10 May 2015 14:34:14 GMT
ETag: "9dd2-515bb27cf250a"
Accept-Ranges: bytes
Content-Length: 40402
Vary: Accept-Encoding
Content-Type: application/javascript
I don't know what i did wrong. Please suggest how to get the updated version of my file via url.
我不知道我做错了什么。请建议如何通过网址获取我的文件的更新版本。
Thanks a lot.
非常感谢。
1 个解决方案
#1
When you send Expires header to browser, it will cache your response and only check for newer version after the expiration date has passed. Since browser won't check for newer version, changing your server settings won't affect browser's cached data. If you made some mistake in your script or there is an update, you can use query string to force browsers to ask for your script.
当您向浏览器发送Expires标头时,它将缓存您的响应,并仅在过期日期过后检查更新的版本。由于浏览器不会检查更新版本,因此更改服务器设置不会影响浏览器的缓存数据。如果您在脚本中犯了一些错误或者有更新,则可以使用查询字符串强制浏览器询问您的脚本。
Assume this is your current script:
假设这是您当前的脚本:
<script src="http://getapple.net/phpbb/banners.js" ></script>
What you need to do:
你需要做什么:
<script src="http://getapple.net/phpbb/banners.js?v=20150510" ></script>
Since URL is not the same, browser will ask for the one with query string and your new settings will be applied!
由于URL不相同,浏览器会询问带有查询字符串的URL,您的新设置将被应用!
#1
When you send Expires header to browser, it will cache your response and only check for newer version after the expiration date has passed. Since browser won't check for newer version, changing your server settings won't affect browser's cached data. If you made some mistake in your script or there is an update, you can use query string to force browsers to ask for your script.
当您向浏览器发送Expires标头时,它将缓存您的响应,并仅在过期日期过后检查更新的版本。由于浏览器不会检查更新版本,因此更改服务器设置不会影响浏览器的缓存数据。如果您在脚本中犯了一些错误或者有更新,则可以使用查询字符串强制浏览器询问您的脚本。
Assume this is your current script:
假设这是您当前的脚本:
<script src="http://getapple.net/phpbb/banners.js" ></script>
What you need to do:
你需要做什么:
<script src="http://getapple.net/phpbb/banners.js?v=20150510" ></script>
Since URL is not the same, browser will ask for the one with query string and your new settings will be applied!
由于URL不相同,浏览器会询问带有查询字符串的URL,您的新设置将被应用!