html页面清除缓存

1、meta标签

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">

HTTP头信息“Expires”和“Cache-Control”为应用程序服务器提供了一个控制浏览器和代理服务器上缓存的机制。HTTP头信息Expires告诉代理服务器它的缓存页面何时将过期。HTTP1.1规范中新定义的头信息Cache-Control可以通知浏览器不缓存任何页面。当点击后退按钮时,浏览器重新访问服务器已获取页面。如下是使用Cache-Control的基本方法:

  1) no-cache:强制缓存从服务器上获取新的页面

  2) no-store: 在任何环境下缓存不保存任何页面

  HTTP1.0规范中的Pragma:no-cache等同于HTTP1.1规范中的Cache-Control:no-cache,同样可以包含在头信息中。

 2、在需要打开的url后面增加一个随机的参数

 var url = 'xxx.html?r=' + Math.random();

 var url = 'xxx.html?tm=' + new Date().getTime();

猜你喜欢

转载自blog.csdn.net/sunyanchun/article/details/130090442