php强制更新图片缓存的方法
Jun 06, 2016 pm 08:10 PM这篇文章主要介绍了php强制更新图片缓存的方法,实例分析了php结合javascript方法实现针对图片缓存的强制更新功能,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php强制更新图片缓存的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
/** 強制更新圖片緩存
* @param Array $files 要更新的圖片
* @param int $version 版本
*/
function force_reload_file($files=array(), $version=0){
$html = '';
if(!isset($_COOKIE['force_reload_page_'.$version])){ // 判斷是否已更新過
setcookie('force_reload_page_'.$version, true, time()+2592000);
$html .= '';
echo $html;
exit();
}else{ // 讀取圖片一次,針對chrome優化
if($files){
$html .= '';
}
}
return $html;
}
// 调用方法
$files = array(
'images/1.jpg',
'images/2.jpg',
'images/3.jpg',
'images/4.jpg'
);
$html = force_reload_file($files, 1);
echo $html;
希望本文所述对大家的php程序设计有所帮助。
,
Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
