Link to home
Start Free TrialLog in
Avatar of cjohnson300
cjohnson300

asked on

Force browser not to cache, or force refresh

I have a html page that uses window.open to open a pdf file in another window.  The problem I am having is that if the pdf has changed, and the browser has opened it recently, the browser returns the cached copy and not the recently changed version.

How can I either force the browser not to ever cache the pdf, or force a refresh on window.open so that the browser goes back to the server to collect the new version of the pdf?

Many thanks in advance
Avatar of mjb001
mjb001
Flag of Austria image

Can you influence the PDF creation or the page displayed by the window.open?
Avatar of cjohnson300
cjohnson300

ASKER

the pdf is created on the first page, say page1.asp and once it is created and saved to the server, i then open the pdf using the same page with the window.open.

So in answer to your question, I think that must be both
Hi,

before sending any data use

<%
    pStr = "private, no-cache, must-revalidate"
    Response.ExpiresAbsolute = #2000-01-01#
    Response.AddHeader "pragma", "no-cache"
    Response.AddHeader "cache-control", pStr
%>

in the ASP file - must be enough.
ASKER CERTIFIED SOLUTION
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
no, but i have now and it seems to works great!  I assume that works because the browser thinks each pdf is a different one because of the suffix on the end?  Does your code allow for random numbers from 0 to 100?
function rand ( n ) {
      return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

rand(100); //random number between 1 and 100