Hello! Today we want to talk about updated header fields in HTTP caching, which are addressed in RFC 9111. This topic is one of the important aspects of web functionality and efficiency, and it helps improve user experience during web navigation.
When a server responds to a HTTP request, it often sends information in the header format for the browser. This information may include expiration date, content type, language, and specific cache data. Caching can reduce page loading time. When you revisit a page, the browser may use some of the data, such as images, CSS files, and JavaScript, cached in memory to access subsequent loads more quickly.
RFC 9111 emphasizes the importance of how HTTP headers can manage caching data to ensure data is always fresh and relevant. This raises the question: if the site content changes, or if new information needs to be sent to users, how can updates be applied?
Old caches can lead users to outdated content and ruin user experience. For this reason, it is necessary to apply strategies for updating cached headers properly. Removing or altering headers such as ETag
or Last-Modified
can instruct the browser to download new content.
For example, if you use Cache-Control: max-age=3600
, inform the browser that this response is valid for one hour. If any change occurs during that time, refreshing the headers will allow the browser to retrieve new data.
Sample Code:
HTTP/1.1 200 OK
Date: Mon, 29 Nov 2021 10:00:00 GMT
Cache-Control: max-age=3600
ETag: "abcde12345"
Last-Modified: Mon, 29 Nov 2021 09:00:00 GMT
Line Explanation:
HTTP/1.1 200 OK
The line indicates the response status is successful.
Date: Mon, 29 Nov 2021 10:00:00 GMT
The date and time when the response was generated.
Cache-Control: max-age=3600
Indicates that the cached response is valid for 3600 seconds.
ETag: "abcde12345"
A unique identifier for the current content that helps the browser determine whether the content has changed or not.
Last-Modified: Mon, 29 Nov 2021 09:00:00 GMT
Indicates the last time the content was modified.