Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Browser Cache Behaves If Local Clock is Not Consistent With Server Clock?

Tags:

http

caching

While reading http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html, I found that the caching algorithm is more complex than I thought.

According to RFC2616, HTTP request is sent if response is fresh. and

response_is_fresh = (freshness_lifetime > current_age)

The current_age can be derived from max-age or Expires header, which both have nothing to do with local clock. However, the calculation of freshness_lifetime depends on local clock.

So, if local clock of browser is not consistent with clock at server side. Is it possible that HTTP caching doesn't exempt unnecessary request sent?

Thanks

like image 920
Morgan Cheng Avatar asked Jun 08 '11 13:06

Morgan Cheng


1 Answers

Their clocks do not have to be in sync, but the client needs a working clock to be able to determine the age of a cached resource and match that against max-age. If max-age is not present in the response, a client could calculate it by comparing the Date and Expires headers to each other.

However, if the client were to suffer from extreme clock skew, the cache would break down and resources could get cached incorrectly since their age can not reliably be determined.

like image 108
Martin Avatar answered Sep 20 '22 13:09

Martin