Understanding HTTP Status Code 304 Not Modified Response and Output Caching Feature in IIS
Published Sep 16 2024 12:53 PM 638 Views
Microsoft

Introduction
Caching plays a crucial role in optimizing web performance. When Output Caching is enabled in IIS for specific file extensions or URLs, it deliver 304 Not Modified status code. This status code is essential for managing caching, as it indicates whether a resource has been modified since the last time it was requested.

 

How it works
The 304 Not Modified status code indicates that a conditional GET or HEAD request was made, and the resource would have received a status code 200 OK response if the specified condition had not evaluated to false. Essentially, this means the server does not need to send the resource again because the client already has a valid copy. As a result, the server instructs the client to use its cached version as if it had received a 200 OK response.
 
When a server sends a 304 response, it must include any headers that would have been sent with a 200 OK response, such as:
 
• Content-Location, Date, ETag, and Vary
• Cache-Control and Expires
 
For demonstration purposes, a site has been hosted in IIS with Output Caching enabled for the .js extension.
HridayDutta_0-1725522262731.png

While browsing the site it is evident that requests for .js files return a 304 Not Modified status code, along with that the server sending an ETag which was matched with the Request Header If-None-Match.

HridayDutta_1-1725522326299.png

Since the purpose of a 304 response is to minimize data transfer when the client already holds a cached version, the server avoids including metadata other than the required fields unless that metadata is necessary for cache management.

 

Conclusion
The HTTP 304 Not Modified status code is used for web caching and performance optimization. It notifies client to use an existing cached copy considering it is able to validate the specified condition catch condition in request header.


References

HTTP status code overview - Internet Information Services | Microsoft Learn

RFC 9110 - HTTP Semantics (ietf.org)

 

Co-Authors
Version history
Last update:
‎Sep 09 2024 06:38 AM
Updated by: