Page Expire

  • Thread starter Thread starter mac
  • Start date Start date
M

mac

Hi!

I've searched the net for ways to expire a page immediately, so when the
user hit 'Back', they receive the "Page Has Expired" error page and I've
seen a number of posts on how to do it - with the code below:

<%
Response.ExpiresAbsolute = #1/1/1980#
Response.AddHeader "cache-control", "no-cache"
Response.AddHeader "pragma", "no-cache"
%>


However, when I try using this code, nothing happens, when I click 'Back',
it simply takes me back to the previous page. The "Expired Page" error page
should display, correct?


Can anyone tell me how this is supposed to be done?
Is there any wrong with my code? or missing?

Thanks,
Mac
 
Thus wrote mac,
Hi!

I've searched the net for ways to expire a page immediately, so when
the user hit 'Back', they receive the "Page Has Expired" error page
and I've seen a number of posts on how to do it - with the code below:

<%
Response.ExpiresAbsolute = #1/1/1980#
Response.AddHeader "cache-control", "no-cache"
Response.AddHeader "pragma", "no-cache"
%>
However, when I try using this code, nothing happens, when I click
'Back', it simply takes me back to the previous page. The "Expired
Page" error page should display, correct?

Only if your browser is IE (this message is browser-specific), and only if
the previous request was a HTTP POST request (i.e. to sumbit form data).
Can anyone tell me how this is supposed to be done? Is there any wrong
with my code? or missing?

That code sample is ASP legacy code. Either use the page directive

<%@ OutputCache Location="None" %>

or

Response.Cache.SetCacheability(HttpCacheability.NoCache);

in your code (behind) file.

Cheers,
 
Back
Top