• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

How can I ensure a .aspx page is NOT loaded from cache?

I have a webpage that will return wrong information if the image is pulled from cache.  Is there a way to make sure that my .aspx page is NOT served up from the browsers cache?
0
tprofits
Asked:
tprofits
  • 2
1 Solution
 
whosbetterthanmeCommented:
There are a few tricks to this, and none of them are completely bullet proof but here are some things to try:

'on the server side
<% Response.CacheControl = "no-cache" %>
 <% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>

'On the client side
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta http-equiv="refresh" content="60" />

Also, another trick others use is to attach a bogus dynamic parameter to the URL such as:

Response.Write("http://myurl.com/myscript.aspx?id=" & now())

This way everytime the url is written, it's different.
0
 
tprofitsAuthor Commented:
I will try this in a few hours.  Thank you!
0
 
Vishal KedarCommented:
Add below page directive

<%@ OutputCache Duration="60" VaryByParam="None" %>
0
 
tprofitsAuthor Commented:
I used Response.Write("http://myurl.com/myscript.aspx?id=" & now()).  Worked nicely.  Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now