How to Disable Images from beeing downloaded into Temp internet folders while accessing a application

In this case the requirement was to disable images from getting downloaded to Temp internet folder (it was an application). This was a security requirement

in this case they were pulling the images from SQL and then using application to display the same after processing

By default IE will download the images to temp internet folders and display from there. It’s not possible to set the size of the temp internet folder to 0 as the minimum size is 8MB

When we set the "Expire Immediately" option for the HTTP HEADER tab of the site. The images stopped appearing in the temp internet folders. But, a aspx page corresponding html page will get downloaded to temp internet folder from where anyone can get to the images easily

When looked in fiddler trace we found that "Cache-Control" header was being sent as "private". This was being transmitted even if we explicitly set the header for "no-cache"

In this case we added the following code to global.asax and we got the expected behavior.

                                protected void Application_BeginRequest(Object sender, EventArgs e)



                                                Response.AddHeader("Cache-Control", "no-cache");


PS: if there is any custom header needed for the application then that needs to be handled as well.


Disclaimer: This is a personal weblog. The opinions expressed here represent my own and not those of my employer.