Corrine
Corrine

Reputation: 203

Is there a way to make Internet Explorer not cache a particular website?

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.

Upvotes: 3

Views: 14651

Answers (7)

Patrick Buick
Patrick Buick

Reputation: 11

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".

Upvotes: 0

Sreeraj
Sreeraj

Reputation: 1

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;

Upvotes: 0

developer747
developer747

Reputation: 15928

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.

Upvotes: 0

Scott Whitlock
Scott Whitlock

Reputation: 13839

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).

Upvotes: 0

Chris K
Chris K

Reputation: 12341

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

Upvotes: 8

phihag
phihag

Reputation: 287745

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.

Upvotes: 6

Sergio
Sergio

Reputation: 8259

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">

Upvotes: 3

Related Questions