Cache me if you can π! A Guide to keep your cache fresh as a daisy with stale-while-revalidate
Today, we are going to talk about an additional tool to help you maintain a fine balance between instancy and freshness when delivering data to your web applications. RFC5861 states two independent Cache-Control extensions that allow for the cache to respond to a request with the most up-to-date response held. 1. The stale-if-error HTTP Cache-Control extension allows a cache to return a stale response when an error such as Internal Server Error is encountered, rather than returning a hard error. This improves availability. 2. The stale-while-revalidate HTTP Cache-Control extension allows a cache to immediately return a stale response while it revalidates it in the background, thereby hiding latency (both in the network and on the server) from clients In this blog, we will be talking more about the stale-while-revalidate HTTP header. The basic idea of this header is to reduce the latency of serving cached content by your web browser to your application and have a refresh mechanism v...