If a server returns Cache-Control=public with no Max-Age or Expires, can a proxy server cache it forever? Do proxies or the spec have a built-in default for these values? Is it always wrong for a server to do this? Thanks.

Cache-Control    public
Content-Length  10874
Content-Type      text/html; charset=utf-8
Server          Microsoft-IIS/7.0
X-Powered-By    ASP.NET
X-AspNet-Version  4.0.30319
Date              Thu, 24 Mar 2011 18:45:52 GMT

Yes, Proxies allways have built in defaults, a large majority of websites don't even give information about how long it can be stored or not so they have to have a default they can use to prevent updated websites from not coming trough.

  • Hi s4uadmin, Interesting, So, yes to all 3 questions? What's a typical default interval? – James Lawruk Mar 25 '11 at 0:15

Bear in mind that caching is not the same as revalidation. A proxy server could cache an object forever, but revalidate it with the origin server every time a request is made for that object (i.e. make an If-Modified-Since or If-Match request which allows the origin server to indicate that the object hasn't changed without returning the object again). If the origin server indicates an expiry (i.e. sends an Expires or Cache-Control: max-age header), the proxy can consider the object to be "fresh" for that period, which means that it doesn't need to revalidate it. If an object is not fresh, it is considered "stale", which means that it must revalidate the object.

Technically proxy servers are supposed to treat objects as stale if the origin server doesn't indicate an expiry, but it seems that most proxy servers treat objects as fresh for a certain period. Squid's default behaviour seems to be

refresh_pattern .               0       20%     4320

which means if the server sent a Last-Modified header, the object is considered fresh for 20% of the difference between the current and last modified times up to a maximum of 4320s (3h), but is never fresh if a Last-Modified header was not sent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.