[英]Java servlet how to disable caching of page
How to disable caching ? 如何禁用缓存?
What headers should doGet set? 应该做什么标题设置?
Could you provide a code snippet? 你能提供一个代码片段吗?
This will set caching to disabled on the response: 这将在响应上将缓存设置为禁用:
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "private, no-store, no-cache, must-revalidate");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
I want to disabled the varnish cache if backend server return some header 如果后端服务器返回一些标头,我想禁用varnish缓存
eg. 例如。
if is set header like follow 如果设置标题如下
JAVA code JAVA代码
ServletActionContext.getResponse().addHeader("ABC","true")
then in varnish if I found value of header ABC as true then I don't want to cache this page. 然后在清漆中,如果我发现标题ABC的值为true,那么我不想缓存此页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.