How to cache a streamed PDF

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.
 
S

sloan

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.
 
B

Bruce Barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top