php – Chrome缓存302重定向

前端之家收集整理的这篇文章主要介绍了php – Chrome缓存302重定向前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 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
原文链接:https://www.f2er.com/php/139224.html

猜你在找的PHP相关文章