ASP.NET MVC Image Caching

I use the code from this article: http://weblogs.asp.net/jeff/archive/2009/07/01/304-your-images-from-a-database.aspx to cache the images that I return from the database but I have a problem when the user changes the image, the browser does not return to the server to check the timestamp.

I tested this on Chrome and IE9, and chrome almost always returns to the server to check the timestamp, and if it has been edited, it returns a new image, IE9 never does it unless I hide Ctrl + F5 to refresh the page.

Is there a cross-browser solution that anyone knows to make sure the browser always makes a call to the server to check the timestamp?

Thanks so much for any help.

+3
source share
2 answers

Setting the expiration date to the current date / time made him always check with the server.

Response.Cache.SetExpires(DateTime.Now);
+1
source

The same user351711 solution with a different syntax:

Response.Cache.SetCacheability (System.Web.HttpCacheability.NoCache);

0
source

All Articles