Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent caching when linking to a generated PDF file

Status
Not open for further replies.

millerk

Programmer
Jul 5, 2002
133
US
I have an app that lets a user enter some parameters, generates a Crystal Report then exports it to a PDF file and provides the user a hyperlink to that file. Sometimes after running multiple reports with different parameters, clicking the link will open a cached version of the file in the Acrobat plugin instead of the new one. I have verified that the correct file is being generated and the old one is being deleted, but the user still gets the old file. Clicking refresh on the IE toolbar brings up the correct file.

Is there a way to force this link to get the new file instead of a cached version? I know with an ASP or HTML page, you can do this in a page directive but I can't figure out how to do it with a PDF file. Is there anything that can be set in web.config that will prevent caching for the whole app? All the app does is generate reports, and they change based on the parameters entered, so I really don't want anything to be cached.
 
Client caching is a serious problem that is only 100% effectively dealt with by changing the url.

So, in this case, you'd need to change the name of the generated .pdf and redirect the user to that file.

It's the only bullet-proof way.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
I'm using the session ID as the file name when I generate the file. I didn't want to change the file name because I need to be able to delete the files using Session ID in the Session_End event.
What I am doing now, which I think is working, is adding a random querystring to the URL that gets set for the hyperlink control. That way, you get a different URL each time, even though the name of the file is the same for a particular session.
 
Perfect. Yes, that will work great.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top