开发者

Firefox max-age based cache expiration behaving weirdly

开发者 https://www.devze.com 2023-04-13 03:46 出处:网络
Im working on a virtual globe web application which serves a lot of map tiles, and i am trying to tweak the http headers that my server is sending to indicate the browser (Firefox) an expiration time

Im working on a virtual globe web application which serves a lot of map tiles, and i am trying to tweak the http headers that my server is sending to indicate the browser (Firefox) an expiration time for it to cache these tiles. The way im doing it is through Cache-Control header and max-age开发者_如何学C parameter.

After a few tests, I realized that caching wasnt working for values below 1799 seconds (approximately 30 minutes). Doing some debugging with firebug net panel, I found out that there is a 30 minutes desynchronization between the client and the server clocks. For example, if the server sends this header indicating a 3600 seconds expiration time:

Date            Fri, 14 Oct 2011 07:46:12 GMT
Server          Apache/2.2.13 (Fedora)
X-Powered-By    PHP/5.2.11
Connection      close
Cache-Control   max-age=3600
Content-Length  47864
Content-Type    image/jpeg

And i browse the cache contents for this request, i get this.

Last Modified   Fri Oct 14 2011 09:16:16 GMT+0100 (Hora de verano GMT)
Last Fetched    Fri Oct 14 2011 09:16:16 GMT+0100 (Hora de verano GMT)
Expires         Fri Oct 14 2011 09:46:11 GMT+0100 (Hora de verano GMT)

Note that client times are GMT+1 and server are GMT, so the real skew is about 30 minutes.

So, the conclusion i get to is that Firefox is computing the expiration time from the server date header rather than the response arrival date on the client, is this right? If so this is a big issue, cause if i set a expiration of 1 hour, a user in China would never cach, how could i work this around? Thanks in advance.


max-age indicates age from the Date header of the response per spec. So yes, if there is clock skew then user-perceived wall-clock times will be off. But that shouldn't affect users in China, unless their clocks are off, because all the dates involved are converted to a canonical timezone before comparing, of course....

I do wonder where you found a server that's not running ntp!

0

精彩评论

暂无评论...
验证码 换一张
取 消