我在注销后使用spring security 4.1.1以及spring 4.3.4和Thymeleaf 3.x,当我点击Chrome浏览器中的浏览器后退按钮时它仍在登录页面但在IE和Firefox中由于缓存其重定向到我点击退出的页面。在重定向页面中,如果我点击任何按钮或链接其指向登录页面,这意味着它是缓存问题,在Firefox中我可以看到它作为BFCache
这是我的securityConfiguration文件
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
RequestMatcher matcher = new AntPathRequestMatcher("/login");
DelegatingRequestMatcherHeaderWriter headerWriter =
new DelegatingRequestMatcherHeaderWriter(matcher,new XFrameOptionsHeaderWriter());
//to disable loading application back button after logout
httpSecurity
.headers()
.defaultsDisabled()
.cacheControl().and()
.contentTypeOptions().and().addHeaderWriter(headerWriter)
.httpStrictTransportSecurity()
.includeSubDomains(true)
.maxAgeInSeconds(31536000).and()
.frameOptions().sameOrigin().xssProtection().block(false);
httpSecurity
/*.csrf()
.disable()*/
.authorizeRequests()
.expressionHandler(webExpressionHandler())
.antMatchers("/forgotPwd", "/resetPwd*", "/successRegister*",
"/registrationConfirm*", "/registration.html", "/user/registration")
.permitAll()
// .antMatchers(HttpMethod.POST,"/api","/api/**").hasRole("ROLE_ADMIN")
.anyRequest().fullyAuthenticated()
.and()
.formLogin()
.loginPage("/login.html")
.defaultSuccessUrl("/home.html")
.usernameParameter("username")
.passwordParameter("password")
.failureUrl("/login.html?error=true")
// .successHandler(myAuthenticationSuccessHandler)
.failureHandler(authenticationFailureHandler)
.permitAll()
.and()
.sessionManagement()
.invalidSessionUrl("/invalidSession.html")
.sessionFixation().none()
.and()
.logout()
.invalidateHttpSession(true)
.deleteCookies("remember-me", "SESSION")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutUrl("/logout")
.logoutSuccessUrl("/login.html")
.permitAll()
.and()
.rememberMe()
.rememberMeServices(rememberMeServices())
.tokenValiditySeconds(86400)
.rememberMeCookieName("remember-me")
.and()
.exceptionHandling().accessDeniedPage("/403");
}
如何让IE和Firefox禁用缓存?
如何禁用此功能?
对于完整的应用程序代码,请检查我的github