views:

542

answers:

4

I am creating a webpage and whenever I refresh or move from page to page, it keeps on just reloading the cache values. But I don't want it to do that because I am working with dynamic data (from the database) so I want it to reload values from the database each time it refreshes, or whenever any page processing is done. And I don't mean just clearing the browser cache. I don't want my end-users to have to go to Tools each time they use my application.

+3  A: 

If you are using asp or aspx try these

<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>

If another place this in the header

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
Sergio
I've already done this but it doesn't seem to work. It still loads data from the cache.
Corrine
+2  A: 

Set the following HTTP headers:

Cache-Control: no-cache
Pragma: no-cache

The first one is for HTTP 1.1, the second one for older clients.

phihag
This doesn't work either. Any other ideas?
Corrine
@Corrine It's unlikely that IE has such a noticeable bug that has gone unnoticed so far. Are you sure you are sending the right headers? Please post a sample request and answer. Does the same behavior occur on a blank page without your code on it? On http://stackoverflow.com? If it does not and stackoverflow(or a demonstration page) works, just compare your headers and the ones that work.
phihag
A: 

Have you checked that you've enabled "reload on every visit" within IE settings?

Internet Options -> General -> Browsing History -> Settings

Check: Everytime I visit the webpage

Chris Kaminski
A: 

I have this problem too, specifically with Internet Explorer 6, and I don't have it with Internet Explorer 8. Here are a list of things to check before ruling it out:

  • In Tools-Internet Options-Temporary Internet Files-Settings... set it to check for newer versions of stored pages "Every visit to the page"
  • Proxies: if you're connected over a VPN, or your company uses a proxy, go to Tools-Internet Options-Connection tab and click on LAN Settings... or the Settings... button along with your VPN connection. Undo any proxy configurations just for a test.
  • Try putting Sergio's suggestion at the very top of your ASPX pages.
  • In the IIS configuration, right click on the web application, go to properties, and click on the HTTP Headers tab, and set content expiration to Expires Immediately. It's a good idea to restart IIS after that, just to make sure.

If none of that works, try different versions of internet explorer. I have a case where I can change a field and click on a button in my web application, it reloads with the new field saved correctly, and the database is updated. Then I go into my back-end application and modify the data manually and save a new value. Then I go back to my web application and click in the title bar and hit the enter key, causing it to reload. In IE6, the refreshed page shows the old data, but if I do this in IE8, it shows the new data. In IE6 I can do two things to make it refresh: clear the temporary files, or modify the URL string by adding &a=123 to the end or something and hitting enter. It's clear to me this is a bug in IE6 (I'm using version 6.0.3790.3959 and it says SP2).

Scott Whitlock