note 48184 deleted from function.header by danbrown
| From: | danbrown@php.net | Date: | Sun, 07 Dec 2008 18:28:55 +0000 |
| Subject: | note 48184 deleted from function.header by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147827@lists.php.net to get a copy of this message | ||
Note Submitter: imoore76 at yahoo dot com
----
I'd been trying to figure out why I couldn't get Internet Explorer to download a file if I
used session_start(). It only happened with certain files. Here's the undocumented (I
couldn't find anything on it) skinny that I've come up with:
If the content type (sent in the Content-type header) is not known to Windows AND the cache-control
header contains 'no-store' or 'no-cache' I.E. will error out. I'm using
WindowsXP Home and I.E. 6.0.
Both 'no-store' and 'no-cache' cause the error by themselves and individually.
I've found that always replacing the header with one that excludes those lines works:
<?
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
?>
This error would happen when using any PHP function (or anything else for that matter) that may set
'no-store' and/or 'no-cache' in the Cache-control header. Provided the content
type is not known to Windows.
E.g.
<?
// this works
header("Content-type: text/plain");
header("Cache-Control: no-store, no-cache");
echo($data);
// this does not work
header("Content-type: foo/bar");
header("Cache-Control: no-store, no-cache");
echo($data);
?>
On a side note, content types are kept in the registry under HKEY_CLASSES_ROOT under each file
extension. My downloads were failing with zip files sent as application/zip. After adding this
content type entry under .zip in the registry, I was able to download the file without a problem.
But this was just to test my theory. Changing the cache-control header was the solution.
I am unsure how/if this effects I.E. on other platforms.