Smart developers will use the HTTP header for Last-modified and ETAGS requests, which can take advantage of caching by clients such as browsers. Because the server first generates the LAST-MODIFIED/ETAG tag, the server can later use it to determine if the page has been modified. Essentially, the client requires the server to validate its (client) cache by passing the token back to the server.
The process is as follows:
- The client requests a page (a).
- The server returns page A and adds a last-modified/etag to a.
- The client presents the page and caches the page along with Last-modified/etag.
- The customer requests page A again and passes the Last-modified/etag that the server returned when the last request was sent to the server.
- The server checks the last-modified or ETag and determines that the page has not been modified since the last client request, directly returning the response 304 and an empty response body.
HTTP response last-modified and ETag