浏览器缓存
3种方式
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <meta name="description" content="描述"> <meta name="keywords" content="关键字"> <meta name="author" content="alanzhang"> <!-- 浏览器缓存设置 合起来用,就可以使你再次进入曾经访问过的页面时,浏览器必须从服务端下载最新的内容,达到刷新的效果 --> <meta http-equiv="pragma" content="no-cache"> <!-- 访问者将无法脱机浏览 --> <meta http-equiv="Cache-Control" content="no-cache,must-revalidate"> <!-- Cache-Control指定请求和响应遵循的缓存机制, no-cache指示请求或响应消息不能缓存, must-revalidate,对于客户机的每次请求,代理服务器必须想服务器验证缓存是 否过时; --> <meta http-equiv="expires" content="0"> <!-- 可以用于设定网页的到期时间。一旦网页过期,必须到服务器上重新传输。 --> </head>
2清理form表单的临时缓存
<form action="" id="login"> <label for="name"> 用户名</label> <input type="text" id="name" autocomplete='off'> </form>
- document.getElementById("login").reset();
- autocomplete='off'
3jquery--ajax清除缓存
<script> $.ajax({ url:'', dataType:'json', cache:false, success:function(response){ } }); $.ajax({ url:'', dataType:'json', beforeSend :function(xmlHttp){ xmlHttp.setRequestHeader("If-Modified-Since","0"); xmlHttp.setRequestHeader("Cache-Control","no-cache"); }, success:function(response){ } }); $.ajax({ //随机时间 url:'YourURL?timestamp='+ new Date().getTime(), dataType:'json', success:function(response){ } }); </script>