Must-revalidate headers of this request wrong?

好久不见. 提交于 2020-01-14 18:55:10

问题


I noticed that chrome cached a video file. I replaced it with another one on the server and chrome kept serving the old one from cache (using JW flash player 5)

The headers of the request look like this:

joe@joe-desktop:~$ wget -O - -S --spider http://www.2xfun.de/files_geheimhihi14/20759.mp4
Spider mode enabled. Check if remote file exists.
--2011-05-15 22:40:56--  http://www.2xfun.de/files_geheimhihi14/20759.mp4
Resolving www.2xfun.de... 213.239.214.112
Connecting to www.2xfun.de|213.239.214.112|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Sun, 15 May 2011 20:40:56 GMT
  Server: Apache
  Last-Modified: Sun, 15 May 2011 20:37:59 GMT
  ETag: "89b38-3bb227-4a35683b477c0"
  Accept-Ranges: bytes
  Content-Length: 3912231
  Cache-Control: max-age=29030400, public, must-revalidate
  Expires: Sun, 15 Apr 2012 20:40:56 GMT
  Connection: close
  Content-Type: video/mp4
Length: 3912231 (3.7M) [video/mp4]
Remote file exists.

I am using mod_headers and mod_expires in apache2 like this:

<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4)$">
ExpiresDefault A29030400
Header append Cache-Control "public, must-revalidate"
</FilesMatch>

Did I spell revalidate wrong or something?

edit:

To make the use case clear: I want the files to be cached, because they are rather big and I want to save bandwidth. But on the other hand I want the files to be re-validated. So the client does a HEAD request and checks whether the content has changed (thats what the etag is for), and only re-fetches if necessary.


回答1:


Your problem is that must-revalidate only kicks in once a cache entry is no longer fresh, but you've marked the response as cacheable for 29 million seconds. 'Cache-Control: max-age=0, must-revalidate' may be closer to what you want, if you want to allow caching but require revalidation on each use.



来源:https://stackoverflow.com/questions/6011123/must-revalidate-headers-of-this-request-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!