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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.