> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/http/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/http/http-2-1/undefined-3.md).

# 캐시 무효화

캐시로 만들지 않는다!

캐시를 적용하지 않는다면 캐시가 안 되는 것 아닌가?\
캐시를 적용하지 않아도 웹 브라우저에서 GET 요청일 때 임의로 캐시를 요청하기도 한다.

이 페이지는 진짜 캐시가 되면 안 되는 경우!!\
ex) 통장 잔고 : 잔고는 계속 바뀌기 때문에 캐시가 되면 안 된다!\
**Cache-Control : no-cache, no-store, must-revalidate**\
**Pragma: no-cache**\
HTTP 1.0에서 요청이 올지도 모르기 때문에!

Cache-Control\
캐시 지시어(directives) - 확실한 캐시 무효화

* Cache-Control: **no-cache**\
  데이터는 캐시에 저장하고 써도 되지만, **항상 원 서버에 검증하고 사용**(이름에 주의!)
* Cache-Control: no-store\
  데이터에 민감한 정보가 있으므로 저장하면 안됨\
  (메모리에서 사용하고 최대한 빨리 삭제)
* Cache-Control: **must-revalidate**\
  **캐시 만료후** **최초 조회시 원 서버에 검증해야함**\
  **원 서버 접근 실패시 반드시 오류가 발생해야함 - 504(Gateway Timeout)=>no-cache와 차이점**\
  **캐시 유효 시간이라면 캐시를 사용함**
* Pragma: no-cache : HTTP 1.0 하위 호환

**no-cache와 must-revalidate 차이점**

![no-cache](https://3778596469-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MdjOVfCTIpivzhg1Bzh%2F-MdpndAwt920rf1fU41Q%2F-Mdpo7oXegpEAHmSPVoJ%2Fno-cache.png?alt=media\&token=c7dd6646-e2ef-4bd0-84b2-c6ebaea60c5a)

![must-revalidate](https://3778596469-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MdjOVfCTIpivzhg1Bzh%2F-MdpndAwt920rf1fU41Q%2F-MdpoBEmJyruUAHoR4Td%2FScreen%20Shot%202021-07-05%20at%205.37.01%20PM.png?alt=media\&token=7ed84011-b9b6-49d3-a512-e48b85b3c072)
