Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am wondering how does IIS (7/7.5) work in terms of 304 ((Not Modified) response code. For example when an image is cached on client side (i.e. a web browser) with the Last-Modified HTTP header set, does IIS need to actually check the if the physical image file has truly been updated? If there are a lot of images this disk IO activity may be the bottle neck even though the images are being cached on client side. Last-Modified will save in terms of data transfered down the wire but not in terms of server disk IO.

The same question can apply to HTTP ETag. I would assume that IIS need to work out the 'content hash' so that browser can figure out whether to fetch an updated page or just use browser cache.

Thanks.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Disk access is indeed required, at least in order to check that the image exists at all (i.e. that a 304, not 404, should be sent).

share|improve this answer
2  
Also to actually check the timestamp held by the filesystem. The file itself need to be read at all if it has not changed, of course. –  David Spillett Nov 11 '10 at 9:42
    
Does this mean if I have a highly trafficked site and most of it serves images, all the images are cached in browser but because the website still needs to perform required DISK IO therefore becomes the bottle neck? –  Jeffrey Nov 12 '10 at 4:39
    
Well, good operating systems usually cache directory entries in memory. So in fact, the web server process asks the operating system "does this (image) file exist at all? what is the modification time of that (image) file?", but the operating system can get answer either from a disk cache or from disk. If the directory is accessed frequently, it is most likely to be fully cached and thus won't become a bottleneck. –  AEP Nov 13 '10 at 13:55

A snip from w3.org, holds true for IIS as well.

If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

Since the header value hasn't changed, IIS does not need to GET the file and hence there should not be any IO. If the header value is inconsistent only then there will be a GET and then the IO.

EDIT: Adding Content Expiration

If you have time-sensitive information on your Web site, you can configure settings that will ensure that obsolete information isn't cached by proxies or Web browsers. You can configure Web site content to automatically expire at any time. When content expiration is enabled, the Web browser compares the current date to the expiration date to determine whether to display a cached page or request an updated page from the server. Server-side technology, such as Microsoft ASP.NET can be used to dynamically change the content served. Typically, time-sensitive information is limited to individual files, directories, or Web sites; however, you can also set content expiration for all Web sites on a computer.

Fiddler trace can help to understand the concept as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.