我有一个页面 index.php,它显示基于 mysql 数据库的信息。上面有表单,表单的操作设置为一个名为 process.php 的单独页面。 Process.php 完成所有数据库 CRUD 的工作,然后使用
header("Location: /webadmin/email/index.php");
将用户送回原始页面。
这似乎工作正常,除了原始索引页面并不总是反射(reflect) process.php 所做的更改。我假设页面正在被缓存,因为如果我刷新(Ctrl + F5),页面将显示最新数据。
如何防止此页面被缓存?我试过what the PHP page for header() says ,但它似乎不起作用。 Cache-Control 和 Expires 选项似乎根本没有效果 - 页面仍在缓存中。
更新
好吧,我错了。显然,以下在 IE 中确实有效:
<?php header("Cache-Control: no-cache, must-revalidate");
但是,它绝对不能在 FF 中工作,它仍然显示缓存版本。关于为什么会这样以及如何让它停止缓存的任何想法?
最佳答案
我会安全地玩,并尝试输出人类(和浏览器)已知的所有缓存 killer 。我的 list 目前包括:
<?php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
关于php - 如何强制不在 PHP 中缓存页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1907653/