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?
tprofitsAsked:
Who is Participating?
 
whosbetterthanmeConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.