加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Chrome缓存302重定向

发布时间:2020-12-13 13:55:48 所属栏目:PHP教程 来源:网络整理
导读:我有一个 PHP脚本用于在网站上旋转横幅图像. 在Firefox / IE页面刷新将发出另一个请求,将返回不同的图像. 在Chrome下,请求似乎已缓存,只有在新选项卡中打开页面才会使其实际查询脚本. 我相信这曾经在旧版本的chrome中工作,我尝试了几种不同类型的重定向代码
我有一个 PHP脚本用于在网站上旋转横幅图像.

在Firefox / IE页面刷新将发出另一个请求,将返回不同的图像.

在Chrome下,请求似乎已缓存,只有在新选项卡中打开页面才会使其实际查询脚本.

我相信这曾经在旧版本的chrome中工作,我尝试了几种不同类型的重定向代码都具有相同的结果.

有小费吗?

< img class =“banner”src =“/ inc / banner.php”alt =“”>

~$cat /var/www/inc/banner.php 
<?php

header("HTTP/1.1 302 Redirect");
header("Cache-Control: max-age=0,no-cache,no-store,must-revalidate");

//header('HTTP/1.1 307 Temporary Redirect');
//header("expires: none");
//header("expires: max");
//header("Cache-Control: public");

$folder = '../img/banner/';

$exts = 'jpg jpeg png gif';

$files = array(); $i = -1;
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ',$exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match('/.'.$ext.'$/i',$file,$test)) { // faster than ereg,case insensitive
$files[] = $file; // it's good
++$i;
}
}
}
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0,$i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); 
flush();
?>

卷曲输出;

~$curl -I -k https://example.net/inc/banner.php
HTTP/1.1 302 Redirect
Server: nginx/1.1.14
Date: Fri,24 Feb 2012 03:23:46 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.10-1ubuntu1
Cache-Control: max-age=0,must-revalidate
Location: ../img/banner/2.jpg
铬中的错误:
http://code.google.com/p/chromium/issues/detail?id=103458

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读