Solved

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

Posted on 2012-04-02
4
239 Views
Last Modified: 2012-06-27
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
Comment
Question by:tprofits
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
whosbetterthanme earned 500 total points
ID: 37798211
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
 

Author Comment

by:tprofits
ID: 37798302
I will try this in a few hours.  Thank you!
0
 
LVL 5

Expert Comment

by:Vishal Kedar
ID: 37800251
Add below page directive

<%@ OutputCache Duration="60" VaryByParam="None" %>
0
 

Author Closing Comment

by:tprofits
ID: 37804502
I used Response.Write("http://myurl.com/myscript.aspx?id=" & now()).  Worked nicely.  Thanks!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now