관리 메뉴

의미없는 블로그

[Appscan] Cache-Control: no-store 본문

카테고리 없음

[Appscan] Cache-Control: no-store

SaltLee 2025. 2. 12. 13:31

Cache-Control: no-store

캐시 금지

모든 요청마다 항상 원본 서버에서 데이터를 가져오도록

브라우저나 중간 캐시(proxy, CDN 등) 에서 가져오지 않도록

이전 요청의 데이터를 재사용 하지 않음

 

이미지, css, js 같은 정적 리소스에는 사용하지 않는것이 좋음

불필요한 네트워크 요청이 증가하여 성능이 저하될 수 있음

 

로그인 페이지 같은곳에, 보안이 중요한 특정 페이지에 설정

 

 

Pragma: no-cache

HTTP/1.0 에서 쓰는것

HTTP/1.1 은 Cache-Control: no-store 로

 

내부망 서비스는 우리만 접속하니까

Pragma: no-cache 안해도 되자나

 

apache (httpd.conf or .htaccess)

<IfModule mod_headers.c>
    Header set Cache-Control "no-store, no-cache, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

 

Java (Spring boot)

import org.springframework.web.bind.annotation.*;
import org.springframework.http.*;

@RestController
public class NoCacheController {

    @GetMapping("/secure-data")
    public ResponseEntity<String> getSecureData() {
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store, no-cache, must-revalidate");
        headers.set("Pragma", "no-cache");
        headers.set("Expires", "0");

        return new ResponseEntity<>("Sensitive Data", headers, HttpStatus.OK);
    }
}
Comments