First, the browser checks the local cache and finds the previous response.
Unfortunately, the browser can't use the previous response because the response has now expired.
In the preceding example, the client automatically provides the ETag token in the "If-None-Match" HTTP request header.
The server checks the token against the current resource.
As a web developer, how do you take advantage of efficient revalidation? The browser automatically detects if a validation token has been previously specified, it appends the validation token to an outgoing request, and it updates the cache timestamps as necessary based on the received response from the server.
The only thing left to do is to ensure that the server is providing the necessary ETag tokens.
To achieve this, the HTTP specification allows the server to return Cache-Control directives that control how, and for how long, the browser and other intermediate caches can cache the individual response.
The Cache-Control header was defined as part of the HTTP/1.1 specification and supersedes previous headers (for example, Expires) used to define response caching policies.
Tip: The HTML5 Boilerplate project contains sample configuration files for all the most popular servers with detailed comments for each configuration flag and setting.
Find your favorite server in the list, look for the appropriate settings, and copy/confirm that your server is configured with the recommended settings.
From a performance optimization perspective, the best request is a request that doesn't need to communicate with the server: a local copy of the response allows you to eliminate all network latency and avoid data charges for the data transfer.
By contrast, the browser can cache "private" responses.
However, these responses are typically intended for a single user, so an intermediate cache is not allowed to cache them.