PHP使用“header("Last-Modified:".gmdate( "D,d M Y H:i:s") . "GMT");header("Cache-Control:no-cache,must-revalidate");”来清除缓存。

推荐:《PHP视频教程》
php清除浏览器缓存
今天在开发过程中遇到一个小问题,后台修改一本书的封面,上传图片后,由于浏览器的缓存导致修改之后,后台还是显示原先的封面,后来加入了两行代码搞定了这个问题。
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );说明:
立即学习“PHP免费学习笔记(深入)”;
header() 函数向客户端发送原始的 HTTP 报头。
Destoon B2B网站管理系统是一套完善的B2B(电子商务)行业门户解决方案。系统基于PHP+MySQL开发,采用B/S架构,模板与程序分离,源码开放。模型化的开发思路,可扩展或删除任何功能;创新的缓存技术与数据库设计,可负载千万级别数据容量及访问。 系统特性1、跨平台。支持Linux/Unix/Windows服务器,支持Apache/IIS/Zeus等2、跨浏览器。基于最新Web标准构建,在
2
认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数
语法
header(string,replace,http_response_code)

header('Location:'.$url); //Location和":"之间无空格。header('content-type:text/html;charset=utf-8');header('HTTP/1.1 404 Not Found');header('Refresh: 10; url=http://www.baidu.com/'); //10s后跳转。header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');header('Content-Type: application/octet-stream'); //设置内容类型
header('Content-Disposition: attachment; filename="example.zip"'); //设置MIME用户作为附件
header('Content-Transfer-Encoding: binary'); //设置传输方式
header('Content-Length: '.filesize('example.zip')); //设置内容长度更多编程相关知识,可访问:编程入门!!
以上就是php如何清除浏览器缓存?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号