PHP sample code to force update image cache

WBOY
Release: 2016-07-25 08:55:22
Original
1149 people have browsed it
  1. /**Force update of image cache
  2. * @param Array $files Image to be updated
  3. * @param int $version version
  4. * @edit bbs.it-home.org
  5. */
  6. function force_reload_file($files=array(), $version=0){
  7. $html = '';
  8. if(!isset($_COOKIE['force_reload_page_'.$version])){ // 判断是否已更新过
  9. setcookie('force_reload_page_'.$version, true, time()+2592000);
  10. $html .= '';
  11. echo $html;
  12. exit();
  13. }else{ // 读取图片一次,针对chrome优化
  14. if($files){
  15. $html .= '';
  16. }
  17. }
  18. return $html;
  19. }
  20. // 调用方法
  21. $files = array(
  22. 'images/1.jpg',
  23. 'images/2.jpg',
  24. 'images/3.jpg',
  25. 'images/4.jpg'
  26. );
  27. $html = force_reload_file($files, 1); //更新缓存文件
  28. echo $html;
复制代码

>>> 您可能感兴趣的文章: 解析 PHP和浏览器缓存机制 超级精练的php缓存类与实例 php ob_start()缓存函数的用法详解 php 文件缓存数据类的代码分享 php立即刷新缓存输出的方法举例 php页面缓存的例子(减经cpu与mysql负担) 一个php缓存类与调用示例 php静态缓存提升网站访问速度的实现代码 php页面缓存ob系列函数的相关介绍 php禁止页面缓存输出的代码 php禁止页面缓存的代码 一个php的页面缓存类



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!