Duncan Benoit
Duncan Benoit

Reputation: 3337

IE history

I generate some png charts and excel files using a mysql database. I display the charts as images in my webapplication, but from time to time IE users don;t have acces to the last version of the files because IE keeps showing to them the previous loaded datas(charts and excel files)

How to prevent happening that? On the client side what can be done?

My web-application is written in PHP. What approach should i use in order to force IE to load the new files?

Upvotes: 1

Views: 245

Answers (3)

boj
boj

Reputation: 11395

HTML meta can work, but using PHP headers are efficient and more correct (look here). The article covers caching downloadable/not html files too.

Caching can be done one of these ways in PHP (use headers before streaming the content of the image):

<?php 
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
    header('Pragma: no-cache'); 
?>

or

 <?php 
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
     header('Cache-Control: no-store, no-cache, must-revalidate'); 
     header('Cache-Control: post-check=0, pre-check=0', FALSE); 
     header('Pragma: no-cache'); 
 ?>

Upvotes: 2

JoshJordan
JoshJordan

Reputation: 12975

Another approach you can use is to add a unique query string to the images you're showing. On the image handler, you can ignore the data that is actually passed on the query string, but IE will treat URLs with different query strings as being unique and therefore require loading each one anew without using a cached version.

For example, changing:

<img src="mychart.png>

to:

<img src="mychart.png?timestamp=0512200911090000">

will get you to avoid the IE cache.

Upvotes: 5

dogbane
dogbane

Reputation: 274562

<HTML><HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD><BODY>
</BODY>
</HTML>

Upvotes: 2

Related Questions