禁用浏览器缓存HTML5 [英] Disable browser caching HTML5
问题描述
我想知道如何使用HTML5禁用浏览器缓存。
I would like to know how to disable the browser cache, using HTML5.
我发现这个有用的帖子(如何控制所有浏览器的网页缓存?),但它只包含HTML4或其他语言的信息。
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.
在我的Web应用程序中,我使用Java( Spring Boot )和 Thymeleaf 来生成HTML5。
我想了解以下HTML标签中HTML5的等效标签:
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" />
无论是通过HTML5标签还是通过Java端解决方案都可以。
It's fine either through HTML5 tags, or even through a Java side solution.
推荐答案
为了使用HTML5禁用浏览器缓存,您可以在Spring Security配置类上执行操作,如示例所示:
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();
}
这篇关于禁用浏览器缓存HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!