# 검증 헤더와 조건부 요청2

**ETag, If-None-Match 정리**

* 진짜 단순하게 ETag만 서버에 보내서 같으면 유지, 다르면 다시 받기!
* **캐시 제어 로직을 서버에서 완전히 관리(핵심)**⭐️
* 클라이언트는 단순히 이 값을 서버에 제공(클라이언트는 캐시 메커니즘을 모름)예)

  ed) 서버는 배타 오픈 기간인 3일 동안 파일이 변경되어도 ETag를 동일하게 유지\
  &#x20;     애플리케이션 배포 주기에 맞추어 ETag 모두 갱신

ETag(Entity Tag)

* 캐시용 데이터에 임의의 고유한 버전 이름을 달아둠\
  ex) ETag: "v1.0", ETag: "a2jiodwjekjl3"
* 데이터가 변경되면 이 이름을 바꾸어서 변경함(Hash를 다시 생성)\
  ex) ETag: "aaaaa" -> ETag: "bbbbb"
* 진짜 단순하게 ETag만 보내서 같으면 유지, 다르면 다시 받기!

![](https://3778596469-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MdjOVfCTIpivzhg1Bzh%2F-Mdpc5vxcEznqS-K0f1u%2F-MdpcDHGawooLbcyGgar%2FScreen%20Shot%202021-07-05%20at%204.44.59%20PM.png?alt=media\&token=d10775a1-c78f-4f14-a637-b0ae596e6439)

서버는 클라이언트에 응답할 때 ETag를 포함해서 보낸다!\
클라이언트는 응답 결과를 캐시에 저장할 때 ETag를 포함해서 브라우저 캐시에 저장한다!

캐시 시간 초과 후, 클라이언트는 캐시가 가지고 있는 ETag를 포함해서 If-None-Match(매치되지 않지?) 서버에 요청한다. 서버는 ETag를 확인하고, Etag가 동일하면 304 Not Modified로 HTTP Body 없이 응답한다.

클라이언트는 응답 결과를 재사용하고, 헤더 데이터를 갱신한다! 캐시에서 조회하여 데이터를 사용한다!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/http/http-2-1/2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
