这应该是一个关于IE8下载问题的老问题。我使用PHP将响应头设置为:
header("Pragma: public");
header("Expires: 0");
header("Content-type: application/octet-stream");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: ".strlen($content));
header("Content-Disposition: attachment; filename='$filename'");
和Connection被Fiddler捕获。
当我尝试在IE8(非SSL)中下载具有上述标题的文件时,消息框:
"Internet Explorer无法打开此Internet站点。请求的站点不可用或无法找到。"弹出并停止下载。
我在网上搜索并尝试了很多解决方案,但似乎没有一个是有效的。这个问题还有别的解决办法吗?
PS:我已经尝试:删除响应头/重置标题中的内容类型/将站点添加到可信站点/将"不将加密页面保存到磁盘"设置为true。
谢谢。
除了Le-roy的回答:
I set
Cache-Control: private, max-age=1
,这为我解决了这个问题。
从Le-roy的链接中,如果设置了以下任何一个:
Cache-Control header with the tokens no-cache, no-store
Vary header that specifies almost anything
Pragma header that specifies exactly no-cache
IE下载失败
当头部设置为no-cache时,IE无法从HTTPS下载文件。更多信息请访问http://blogs.msdn.com/b/ieinternals/archive/2009/10/02/internet-explorer-cannot-download-over-https-when-no-cache.aspx