Background:
I have a web portal in .NET 3.5 on the IIS 6 web server. Currently there is a page that is set to a value, and based on that value, the PDF file is viewed in the web service and the result is displayed to the user in another tab on the web page . This is done using the following code.
context.Response.ClearContent(); context.Response.ClearHeaders(); context.Response.Clear(); context.Response.AddHeader("Accept-Header", pdfStream.Length.ToString()); context.Response.ContentType = "application/pdf"; context.Response.BinaryWrite(pdfStream.ToArray()); context.Response.Flush();
It works and works for many years. However, we had a problem with the client that a particular client had a PDF file that was returned as the same PDF file each time, until it cleared the temporary Internet cache.
I thought it was cool, it's simple. I will simply add cache headers in the response so as not to cache it. So I added the following:
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);//IE set to not cache context.Response.Cache.SetNoStore();//Firefox/Chrome not to cache context.Response.Cache.SetExpires(DateTime.UtcNow); //for safe measure expire it immediately
After a quick test, I got exactly what I expected in the response header.
Cache-Control no-cache, no-store Pragma no-cache Expires -1
Problem:
So it went live. Everything seemed cool. The next day, bam, everyone started getting white screens and didn't display the PDF. After further investigation, I found out that this is only IE 6,7,8. Chrome is fine, Firefox is great, Safari is great, even IE 9 is great. Not knowing why this happened, I canceled my change and deployed it, and it all worked again.
I searched everything, trying to figure out why my caching headers seem to confuse IE 6-8 to no avail. Has anyone encountered this type of problem with IE 6-8? Is there something I'm missing? Thank you for understanding.