如何防止php站点的浏览器缓存 [英] How to prevent Browser cache for php site

查看:119
本文介绍了如何防止php站点的浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在云服务器上运行的php网站。当我添加新文件css,js或images时,浏览器正在加载存储在缓存中的相同的旧js,css和图像文件。

I have a php site running in cloud server.When ever i add new files css, js or images the browser is loading the same old js, css and image files stored in cache.

我的网站有一个doctype和meta标签,如下所示

My site has a doctype and meta tag as below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)">
  <meta http-equiv="Page-Exit" content="blendTrans(Duration=1.0)">
  <meta http-equiv="Site-Enter" content="blendTrans(Duration=1.0)">
  <meta http-equiv="Site-Exit" content="blendTrans(Duration=1.0)">

由于上面的doctype和元代码我加载了在浏览器中缓存的相同文件而不是新文件

Because of the above doctype and meta code am i loading the same files cached in browser instead of new one

推荐答案

试试这个

<?php

header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>

这篇关于如何防止php站点的浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆