Imagine that a user request page.htm in its browser. It travels through the internet and one of proxy server (P1) serves a cached version. Then, the user refreshes the page, another request travels through the internet and reaches proxy server P2, which serves a document that was cached at a different moment. The user sees 2 different contents.
开发者_Go百科Question: Could this happen ?
Assuming that the expiry policy is set to an absolute date, that would not happen. (Well in theory, because the server clocks are not necessarily synchronised). But what about relative time window cache policies ?
If it can happen, how do you get around the potential issue ?
Yes, it can happen.
There are several ways to deal with it:
Set an absolute expiration date like you suggest.
Prevent caching for proxies by sending
Cache-Control: s-maxage=0, proxy-revalidate
However, I'm not sure all proxies would honor this.If you know you're soon going to change a certain page, turn down its cache TTL to a very short period. Proxies will then keep revalidating that page with short intervals. Once the new page is out, it should quickly get picked up and you can turn back the TTL to a larger period.
精彩评论