473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How can I stop PDF docs from caching on my website?

I am working on a ASP.NET 2.0 web site that has some PDFs that users can
download. I'm using an HTTP module to see if the user has permission to view
the PDF before loading it. This all works great. The problem is that once
the PDF has been allowed through to the browser, it won't be denied to the
next user. So, if one user is allowed to see it and then a user who is not
allowed to see it uses the same browser, it comes through for them. If I
clear the cache on the browser, it works again. I think that once the PDF
doc comes through, the browser is caching it. How can I prevent this caching
from my web code? Thanks.
Nov 19 '05 #1
2 8179
On Tue, 19 Jul 2005 10:01:10 -0500, lanem
<la***@discussions.microsoft.com> wrote:
I am working on a ASP.NET 2.0 web site that has some PDFs that users can
download. I'm using an HTTP module to see if the user has permission to
view
the PDF before loading it. This all works great. The problem is that
once
the PDF has been allowed through to the browser, it won't be denied to
the
next user. So, if one user is allowed to see it and then a user who is
not
allowed to see it uses the same browser, it comes through for them. If I
clear the cache on the browser, it works again. I think that once the
PDF
doc comes through, the browser is caching it. How can I prevent this
caching
from my web code? Thanks.


The easiest way to avoid caching is to not link to the pdf file directly,
but create an aspx file that 'serves' the file to the user. Then you can
set headers, etc. appropriately to keep it out cache, or add a unique
querystring argument to the .aspx URL when you call it....

An example of streaming:
http://www.ondotnet.com/pub/a/dotnet...04/01/asp.html

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2
Thanks. That worked great. I can get it to work now using the streaming
stuff. I also figured out my previous problem, caching of the pdf pages. I
fixed this by putting a response.expires = -1 in my HTTP Module. So now,
both methods work. Which do you think is better and more secure? Using an
HTTP module or using this streaming solution? Thanks.

"Craig Deelsnyder" wrote:
On Tue, 19 Jul 2005 10:01:10 -0500, lanem
<la***@discussions.microsoft.com> wrote:
I am working on a ASP.NET 2.0 web site that has some PDFs that users can
download. I'm using an HTTP module to see if the user has permission to
view
the PDF before loading it. This all works great. The problem is that
once
the PDF has been allowed through to the browser, it won't be denied to
the
next user. So, if one user is allowed to see it and then a user who is
not
allowed to see it uses the same browser, it comes through for them. If I
clear the cache on the browser, it works again. I think that once the
PDF
doc comes through, the browser is caching it. How can I prevent this
caching
from my web code? Thanks.


The easiest way to avoid caching is to not link to the pdf file directly,
but create an aspx file that 'serves' the file to the user. Then you can
set headers, etc. appropriately to keep it out cache, or add a unique
querystring argument to the .aspx URL when you call it....

An example of streaming:
http://www.ondotnet.com/pub/a/dotnet...04/01/asp.html

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Larry Neylon | last post by:
Hi, I am having problems with our IIS6 server serving out of date javascript files in our ASP scripts. It appears to be an intermittent problem, but causes all kinds of headaches when working...
8
by: Nick Gilbert | last post by:
Hi, Our development web server (Win 2003 Server) seems to be caching the output of various files (CSS and .aspx files) if they have no query string. The moment you put a question mark in the...
29
by: Vjay77 | last post by:
I have a timer which triggers AxWebBrowser1 every 5 minutes to visit one of my websites. What I find out later in my websites logs, was, that it really visited my website only for the first...
6
by: Steve Mauldin | last post by:
I have three websites that were developed by using the same code in .net. They are all located under wwwroot on my desktop running windows 2000 pro.because Windows 2000 pro only supports a single...
3
by: Alex Greenberg | last post by:
Hi, I'm having a strange problem: I have a product.aspx page where the admin can change product properties, including the JPEG. The JPEG will always have the same name: eg. 120.jpg and in...
0
by: docsearch | last post by:
Hi all, I've made a "LAMP docs" search website and want to collect PHP-related docs as much as possible. It now covers PHP, Apache, MySQL and Smarty. I'm looking for usefull online documentaion...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.