chrome php 禁用缓存,php – Chrome缓存302重定向

我有一个

PHP脚本用于在网站上旋转横幅图像.

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

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

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

有小费吗?

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

~$cat /var/www/inc/banner.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, no-cache, no-store, must-revalidate

Location: ../img/banner/2.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值