标签:
有时为了实现一些功能(例如实时刷新数据),需要浏览器不使用缓存,而是一直从服务器获取数据。
HTTP 头“Expires”和“Cache-Control”提供了一个控制浏览器和代理服务器上缓存的机制
Expires 告诉浏览器,它的缓存页面何时将过期,可以为0
Cache-Control 通知浏览器不缓存任何页面
两个头都在 RFC7234 中定义
对于 HTML 页面, 使用
<meta HTTP-EQUIV="pragma" CONTENT="no-cache"> <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <meta HTTP-EQUIV="expires" CONTENT="0">
控制
对于 jsp 或 servlet, 使用
response.setHeader("Cache-Control","no-store"); response.setHeader("Pragrma","no-cache"); response.setDateHeader("Expires",0);
控制
标签:
原文地址:http://my.oschina.net/MiluDeer/blog/490567