Solved

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

Posted on 2012-04-02
4
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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