Scott Hanselman

Understanding why your updated images don't immediately get served to Browser Clients

June 17, 2003 Comment on this post [2] Posted in Web Services | XML | Tools
Sponsored By

This is a complex topic, but here's a cursory explanation:

 

The Web Server, in this case IIS, sets Content Expiration info and information about then things are modified in the HTTP Headers.  If you ask for something from the Web Server, but you say "only if modified since..." they will pass back “Not-Modified” HTTP Headers to the Browser. You can see this even when hitting F5 to refresh the browser if you use a tool like ieHTTPHeaders (http://www.blunck.info/iehttpheaders.html) .  Look at IE Content Expiration in the Properties. 

Most folks like to have a “/images” folder that has SEPARATE Content Expiration settings and static content, or many levels of image volatility.

 

You have a few possible solutions:

 

·         Have volatile (often changing) images stored in one folder and set to expire immediately or on your specific schedule. 

·         Have the Browser user press CTRL-F5 to “blow through the cache”…F5 in IE will NOT fetch updated images until they expire. Pressing CTRL-F5 will keep the browser from including “If-Not-Modified” – which is equivalent to saying “get it anyway.”

·         Check the GET requests of your images in the HTTP Headers to see when they will expire...then wait. ;)

·         If you are generating the images yourself (dynamically generated on the server side) then you control the headers, so you can force updates by writing the appropriate headers yourself.

A picture named image001.jpg

Notice in this screen shot that even though I pressed F5, the Web Server responded “This image hasn’t been modified!”

A picture named image002.jpg

Even more, this request from the browser specified “Only give me this image if it’s been modified since a certain date.”

A picture named image003.jpg

The moral of this story is, you'll never know the WHY of the behavior of your system unless you know both the HOW of the HTTP Spec and the QUIRKY HOW of the browser whose behavior you're examining.

 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
June 18, 2003 21:39
I've had many run-ins with this only from interpreting the client request. A recent client has a graphics preloading script that occassionally wigs out (very rare) and both looking from the logs (which post the 304) and using WFetch to simulate this, it's very real issue. It's more of an issue if you are having to deal with Proxy servers caching content rather than a simple client.

June 18, 2003 21:46
Gracias!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.