How to Prevent Caching When Using PDF Streaming with Acrobar Reader 10.0 (HTTP1.0 / HTTP1.1)

I was trying to find a way to prevent browsers from loading a PDF that loads using streaming methods.

FireFox and Chorme do a great job with the following headers and don't cache any pdf file:

Response.AddHeader ("Pragma", "no-cache, no-store"); Response.AddHeader ("Cache-Control", "no-cache, no-store, must-revalidate, max-age = 0"); Response.AddHeader ("Expires", "-1");

Although IE 7 (with acrobat 9.4.1 reader) only works with the following headers and prevents caching of the PDF document:

Response.AddHeader ("Pragma", "no-cache, no-store"); Response.AddHeader ("Cache-Control", "private, must-revalidate, max-age = 0"); Response.AddHeader ("Expires", "-1");

When I tried to use IE 7 with Acrobat Reader 10, the above header did not make any changes and cached the PDF no matter what I tried.

When I try to install Cache-Control: no-cache, no-store, the pdf file was not loaded at all. In my opinion, IE uses a caching mechanism to load PDF documents.

Is there anyone familiar with a global or specific way (e.g. using other headers) that can help prevent caching of PDF documents?

+7
source share
4 answers

Add a random number to the URL, either to the path or to the query string. This way it will download the file every time. You can also only change the number if the file has been changed, for example, using the mtime file.

PHP (as everyone understands this, even if someone doesn't like it):

<a href="document.pdf?buster=<?= time() ?>">Download PDF</a> 
+7
source

This problem with displaying PDFs (and other types of documents), embedded using the no-cache header, was reported as a bug for Microsoft: http://support.microsoft.com/kb/316431 . IE uses its own caching mechanism when reading embedded PDF files.

Unfortunately, people at M $ said it "works as designed" and users should not use the no-cache ... go figure header.

You can try using VSU with a Java PDF reader ... I can go that way too.

+1
source

Managing cache settings by channel is not proof of a fool. An alternative is real-time and date encoding in the PDF file name.

0
source

You can encode the time date in the PDF file name so that each time a request is made, the file name is unique.

Response.AddHeader "Content-Disposition","attachment;filename=somename" + CurrentDate() + Currenttime() ".pdf"

CurrentDate adn CurrentTime are imaginary functions. You need to write this code.

0
source

All Articles