의미없는 블로그

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

카테고리 없음

[Appscan] Cache-Control: no-store

SaltLee 2025. 2. 12. 13:31

Cache-Control: no-store

캐시 금지

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

 

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