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.
-
What server-side language are you using? – Daniel A. White Jul 07 '09 at 15:46
-
I am using JavaScript with jQuery and Java Servlet with PL/SQL to retrieve values from the database. – Corrine Jul 09 '09 at 19:46
7 Answers
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

- 11,996
- 7
- 37
- 65
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.

- 278,196
- 72
- 453
- 469
-
@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 Jul 10 '09 at 00:50
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">

- 8,125
- 10
- 46
- 77
-
I've already done this but it doesn't seem to work. It still loads data from the cache. – Corrine Jul 09 '09 at 18:39
I had 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).

- 90,639
- 22
- 233
- 295

- 13,739
- 7
- 65
- 114
Do get around the caching issue, what we do at our work place is to append a random number or current datetime to the requested url.
Since IE looks up the cache by the exact url (including the query string), it doesn't find the cached values and hence fetches a fresh page.

- 15,419
- 26
- 93
- 147
You just change the refreshing URL by appending the current time in milliseconds to the url.So every time the page refreshes, the URL also changes with the time parameter.So caching will not take effect..
var mSeconds = new Date().getTime() / 1000;
var url = 'www.mysite.com/test.do?time=' + mSeconds;

- 1
I am working on a dynamic page now and have found with IE 10 Preview that I cannot make it refresh. I have the following headers (taken from View Source):
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
I also have checked the settings for IE itself and changed the url for the main page (but not the underlying php calls used by the page). It is only when I first start it up that it actually refreshes the page and shows current data. I can even close the tab and open the url in a new tab and it brings up the cached data.
@developer747 and @Sreeraj : I had to use the random number trick to change the url for the underlying requests for data, as they apparently were being cached, defeating the purpose of using xmlhttpRequest to retrieve dynamic content in the first place. FireFox, Chrome, Safari and Opera did not need this "trick".
-
Although I feel sorry you have this problem, this is not really an answer to the question. – Jelle Feb 07 '13 at 16:40