1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php清理浏览器缓存文件在哪里 php如何清除浏览器缓存?

php清理浏览器缓存文件在哪里 php如何清除浏览器缓存?

时间:2020-01-04 06:08:46

相关推荐

php清理浏览器缓存文件在哪里 php如何清除浏览器缓存?

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" );

说明:

header() 函数向客户端发送原始的 HTTP 报头。

认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数

语法header(string,replace,http_response_code)

PHP header 的7种用法1. 跳转页面header('Location:'.$url); //Location和":"之间无空格。2. 声明content-typeheader('content-type:text/html;charset=utf-8');3. 返回response状态码header('HTTP/1.1 404 Not Found');4. 在某个时间后执行跳转header('Refresh: 10; url=/'); //10s后跳转。5. 控制浏览器缓存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");6. . 执行http验证header('HTTP/1.1 401 Unauthorized');

header('WWW-Authenticate: Basic realm="Top Secret"');7. 执行下载操作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')); //设置内容长度

更多编程相关知识,可访问:编程入门!!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。