【发布时间】:2017-05-31 14:24:26
【问题描述】:
我有一个 PHP 脚本可以从文件服务器下载 KML 文件。下载部分有效,但下载的文件是存储在文件服务器上的文件的旧版本。
我尝试设置 Cache-Control 和 Pragma 标头,但在使用 PHP URL 下载文件时仍会传递旧版本的文件。我在多个浏览器上进行了尝试,并确认最新版本的 KML 文件位于文件服务器上。
我错过了什么?
编辑:即使更改 header('Content-Disposition.. 中的文件名.. 也不会更改下载文件的文件名。我在我尝试过的所有 3 个浏览器上都得到了完全相同的旧文件。它开始看起来像一个网络服务器配置问题?
<?php
//Update the date in the filename with new releases
header('Content-Type: application/vnd.google-earth.kml+xml kml');
header('Content-Disposition: attachment; filename="KML Repository (2017-05-31).kml"');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
readfile("KML Repository (2017-05-31).kml");
?>
【问题讨论】:
-
要放弃 Web 服务器配置问题,您可能需要检查浏览器接收到的实际标头
标签: php header kml readfile cache-control