반응형
웹페이지(jsp, html)에서 뒤로가기를 했을 때 'ERR_CACHE_MISS' 에러가 발생한 적이 있다
이럴 경우 아래와 같이 해결하면 된다!
- jsp나 html과 같은 웹페이지 상단에 header 추가
response.setHeader("Cache-Control","no-cache);
response.setHeader("Pragma","no-cache");
- spring 설정에서 공통으로 처리
본인은 csrf 처리 때문에 WebSecurityConfigurerAdapter를 상속받은 classs가 있었고, configure 메소드를 오버라이드하여 csrf 방어코드를 세팅하였다. 그래서 이 부분에 캐시 방지 코드를 추가하여 작성함!
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers(headers -> headers.cacheControl(cache -> cache.disable()))
//CSRF 방어코드
.csrf().ignoringRequestMatchers(new CsrfIgnoringRequestMatcher(this.excludeUrl));
}
728x90
반응형
'개발 > Web' 카테고리의 다른 글
[Spring Boot] spring security - CSRF 적용 , +) ajax csrf 적용 (0) | 2021.12.07 |
---|---|
[Spring Boot] mybatis 적용하기 (0) | 2021.12.06 |
[Apache] web-was 연동, socket_timeout 설정 이슈 (0) | 2021.11.30 |
[Tomcat] JNDI 정보 암호화(DB정보 : url, username, passowrd) / KDF 알고리즘 이용 (0) | 2021.11.30 |
[Spring] Scheduler(스프링 스케줄러) 설정하기 (0) | 2021.11.30 |
댓글