Stale content is the one that has expired in cache. It’s widely known that CDN (content delivery network) doesn’t keep an object in cache forever: every file has a TTL (Time to live), and as soon as it reaches zero, the object expires. After that, CDN must contact the origin server to send the object to visitors.
What happens when the CDN network gets a request for a file that has expired in cache, and its fresh version is unavailable in the origin server? Should in send a timeout error, or serve a stale object?
Serve stale means that a content delivery network sends an expired object from the cache, if the origin server doesn’t respond, or returns an error. The truth is that in most cases it is better for a visitor to receive an expired/outdated response from CDN rather than an error response, or a timeout.
Some CDN providers serve stale by default (for instance, Highwinds), while others have serve stale as a feature that can be activated. Besides, some CDN services support HTTP Cache-Control Extensions for Stale Content, which means that the user can control settings of stale content served from headers the origin sends. Besides, serve stales is not the same on all CDNs. For instance, Verizon Digital Media Services has two features:
- - Stale content Delivery on Error. CDN caches will send stale content, if an error occurs when establishing connection with an origin server. Note that responses from the origin like 404 or 502 will be passed to the visitor.
- - Stale While Revalidate. The user can set up the length of time and select a period (minutes, hours, etc.) to allow delivery of stale content.
Both features come at a price. Doubt whether you need to pay for that? Imagine a client who can’t access your website and get desirable content: most likely, he will go to your competitors’ website. But if a visitor gets the piece of information he searched for, the problem of stale content may stay unnoticed by him. Loss of potential customer is worth thousands of dollars, while delivery of stale content costs much less. Thus, “serve stale” is an option that can save you from highly negative customer experience, which definitely makes it worth paying for.