Disable browser caching HTML5

扶醉桌前 提交于 2019-12-11 18:23:52

问题


I would like to know how to disable the browser cache, using HTML5.

I found this useful post (How to control web page caching, across all browsers?), but it contains the info only for HTML4 or other languages.

In my web application I use Java (Spring Boot) and Thymeleaf to produce HTML5. I would like to understand what are the equivalent tags for HTML5, of the following HTML tags:

<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0" />

It's fine either through HTML5 tags, or even through a Java side solution.


回答1:


In order to disable the browser cache with HTML5, you can act on the Spring Security configuration class, as in the example:

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
...
@Override
protected void configure(final HttpSecurity http) {
   ...
   http.headers().cacheControl().disable();
}



回答2:


For disable the browser cache with HTML5 in response header you can view this post automatically add header to every response.

For application made in Spring annotation-based see https://stackoverflow.com/a/49431665/4939245



来源:https://stackoverflow.com/questions/49401531/disable-browser-caching-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!