Jump to content

Excel Caching Issue


jayR

Recommended Posts

Hello.  I'm generating some stats in my php script and I am also generating an excel file at the same time so that it can be downloaded and worked with.  The problem is that for some reason the Excel file won't update when the stats do, like its cached or something.  The file on the server is updated but thats it.  I know that you need headers to tell it not to cache, but I don't know where to put the headers.  The page the link is on currently has these headers:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-Type: text/html; charset=utf-8");

and has other information that shouldn't be cached on it and it is working fine.  I also found a post that says to use these headers:

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=$csvnameext­");
header("Expires: Mon, 3 Jan 2000 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

These, however, make links pointing to this page treat it like an excel document, not a web page that simply has a link to an excel document.  If theres anything else you need to help solve this let me know.  Thanks.
Link to comment
https://forums.phpfreaks.com/topic/16131-excel-caching-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.