How to cache a streamed PDF

  • Thread starter Thread starter Kris
  • Start date Start date
K

Kris

Hi,

I have an ASP.net application where I store PDFs in a database as binary
data. The web interface binary writes a specific PDF to the browser
based on user selections. Some of these PDFs are rather large, so it
would be nice if the client's browser would cache the file. However, I
haven't been able to make things work this way. Is there anything
specific that I can do? I'm thinking I might be able to change a few
things in the Response headers, but I'm not that familiar with them to
know. Any help would be greatly appreciated.
 
I don't think you can cache byte streams.

You'd have to consider... writing the file out on the WEB SERVER, and giving
the user the hardcoded href.

Perhaps then... with a href, it might cache.

I don't know this as a fact for pdf's though.

Consider the use of GUID's for the filenames.

...
Of course, you then gotta clean up all those files.
 
set the expiration header when you stream the pdf.

Response.Cache.SetExpires(DateTime.Now.AddDays(1));

and the browser will cache it.

-- bruce (sqlwork.com)
 
Back
Top