[英]How do I set Cache-Control/Expires Headers
I want to use expires headers or Cache-Control, but I don't know how to do that. 我想使用过期标头或Cache-Control,但是我不知道该怎么做。 I searched a little bit on Google and I found different tags but I don't know if it's ok to use them or whether it's deprecated.
我在Google上进行了一些搜索,发现了不同的标签,但我不知道可以使用它们还是不建议使用。
Example: 例:
<META HTTP-EQUIV="Cache-Control" CONTENT="max-age=86400, must-revalidate">
I use Tomcat server and also found different methods to do that directly on server through web.xml
file (which isn't working trough server settings). 我使用Tomcat服务器,并且还发现了不同的方法通过
web.xml
文件直接在服务器上执行此操作(该操作不适用于服务器设置)。
If anyone can help me with a solution I will really appreciate. 如果有人可以帮助我提供解决方案,我将不胜感激。
Thank you. 谢谢。
In the Servlet.service method 在Servlet.service方法中
response.setHeader("Cache-Control", "max-age=86400, must-revalidate");
Or put that in a filter. 或将其放入过滤器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.