note 48184 added to function.header
| From: | imoore76atyahoodotcom at osu1 dot php dot net | Date: | Tue, 14 Dec 2004 21:12:47 +0000 |
| Subject: | note 48184 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81796@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48184
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48184&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48184&report=yes
Search -- http://master.php.net/manage/user-notes.php