참고 자료 · 63

HTTP 캐싱: 개인화된 응답 보호

공유 캐시, 개인 캐시 및 애플리케이션 캐시를 분리하고, 키, 재검증 및 액세스 권한 변경 후 무효화를 검사합니다.

업데이트됨 · 12 min

사람 없는 보안 서버 및 네트워크 통로 AI로 생성한 편집용 일러스트

이 가이드가 달성하는 목표

  • 계층 목록 작성
  • 보존 기간 선택
  • 키 검사
  • 재검증 및 변경 실행

빠른 확인

  • 캐시 없음은 아무것도 보존되지 않는다는 의미인가요?
  • Vary는 접근 권한을 보호하나요?
  • 모든 API를 캐시해야 하나요?

단계별 방법

  1. 1

    계층 목록 작성

    브라우저, CDN, 프록시, 서비스 워커 및 애플리케이션 캐시 목록 작성. 공개 응답과 개인화된 응답 분류. HTTP 정책은 코드로 구현된 캐싱을 자동으로 설명하지 않습니다.

    결과물: 계층 및 소유자 다이어그램

  2. 2

    보존 기간 선택

    RFC 9111은 지시문을 구분합니다. no-cache는 재사용 전 유효성 검사를 요구하고, no-store는 관련 HTTP 저장소를 금지하며, unqualified private는 공유 저장소를 제외합니다. 어느 하나만으로는 시스템 기밀성을 보장할 수 없습니다.

    산출물: 응답별 보존 정책.

  3. 3

    키 검사

    표현 변경 시 메서드, URI 및 차원을 확인합니다. 변경 사항은 요청 필드와 관련이 있으며 권한 부여와는 무관합니다. 애플리케이션 계층에서 누락된 언어, 형식 협상 및 계정 컨텍스트를 확인합니다.

    산출물: 키 및 분리 테스트.

  4. 4

    재검증 및 변경 실행

    최신 및 오래된 응답, 데이터 업데이트 및 권한 취소 테스트를 수행합니다. ETag, 조건부 유효성 검사 및 출처를 사용할 수 없는 동작을 검사합니다. 이전에 올바랐던 응답도 권한 취소 후에는 민감한 정보가 될 수 있습니다.

    결과물: 전후 추적 데이터

  5. 5

    두 개의 계정을 사용한 재현 테스트

    가상의 신원 및 마커 사용. 웜 캐시와 콜드 캐시를 사용하여 동일한 URI에 대한 요청을 번갈아 수행. 실제 토큰을 기록하지 않고 로그아웃, 직접 링크 및 로깅 기능 확인.

    결과물: 네거티브 테스트 및 무효화 전략. 결과물: 두 계정으로 재현 테스트 수행.

캐시 속도와 최신성 함께 측정하기

가상 예시입니다. 고객이나 실제 관측 결과를 나타내지 않습니다.

상황

두 번의 읽기는 모두 빠르지만, 원본이 바뀐 뒤에도 하나는 이전 가용 상태를 보여 줍니다.

확인

값, 버전, 읽은 위치, 변경 후 시간을 비교합니다. 시스템 계약에 따라 무효화, 만료, 원본 접근을 시험합니다.

조치

데이터가 얼마나 오래되어도 되는지 용도별로 정하고 차이를 감시합니다. 지연 감소만으로 제공 데이터의 일관성을 입증할 수는 없습니다.

재사용 가능한 워크시트

승인된 의견을 기입하십시오. 이 항목들은 작업 템플릿이며, 관찰된 결과가 아닙니다.

필드기록할 정보
대응공개 또는 개인화; 차원
계층캐시, 소유자 및 키
정책보존, 최신성 및 유효성 검사
시험가상 계정, 변경 및 관찰

가상 예시

예시 상황

가상 예: CDN이 두 개의 테스트 계정에 대해 동일한 URI에서 프로필 응답을 재사용합니다.

결정 및 예상 증거

이 시나리오는 정보 유출을 감지하고 정책 및 키를 검사한 다음 수정 및 액세스 취소 후 다시 실행합니다.

메커니즘 구분

메커니즘목적검증 또는 제한
캐시 없음필수 유효성 검사를 통한 저장 허용저장 안 함으로 해석하지 마십시오
자격 미달 개인 정보공유 캐싱 제외기밀성 보장으로 해석하지 마십시오
저장 안 함관련 HTTP 저장 방지애플리케이션 캐시 및 기록 별도 확인

관리 지표

지표측정 대상첫 번째 조치
계정 분리다른 계정의 마커 없음본문, 링크 및 메타데이터 검사
기간 및 유효성 검사정책에 따른 재사용만료 및 사용 불가능한 출처 테스트
무효화 지연수정된 표현까지의 시간아직 유효하지 않은 각 계층 이름 지정

일반적인 실수

  • 저장 안 함으로 해석하지 마십시오
  • 기밀성 보장으로 해석하지 마십시오
  • 애플리케이션 캐시 및 기록 별도 확인

자주 묻는 질문

캐시 없음은 아무것도 보존되지 않는다는 의미인가요?

아니요. 재사용 전에 유효성 검사가 필요하며, 저장 안 함처럼 저장을 금지하지 않습니다.

Vary는 접근 권한을 보호하나요?

아니요. 표현 선택에 참여합니다. 권한 부여는 별도로 유지됩니다.

모든 API를 캐시해야 하나요?

아니요. 이점은 비용, 최신성 및 위험에 따라 다릅니다. 민감한 응답의 경우 공유 캐시를 사용하지 않는 것이 타당할 수 있습니다.

ETag, HTTP 캐시 및 동시 변경

이 언어판의 상세 참고 설명은 영어로 제공됩니다.

ETag: revalidate responses and prevent lost updates

An ETag is an opaque validator for the selected representation. It compares versions; it is neither authorisation nor an access token, and it need not be a file hash. Personalised responses require separate decisions about access, cache selection and HTTP conditions.

Local teaching model: a representation already exists; at most one conditional field contains a single ETag or *. GET, HEAD and PUT are covered. Tag lists, date validators, ranges, creation, combined conditions and the already-succeeded modification exception are excluded. No network call, storage or state change occurs; this does not test your API.

사람이 없는 가상의 네트워크 실험실. 호박색 조명의 어두운 작업대 위에 장비가 놓여 있다. AI로 생성한 편집용 일러스트
Generated conceptual scene: a fictional empty network laboratory. It shows neither a real facility nor a protocol measurement.

Strong and weak ETag comparison serve different purposes

If-Match requires strong comparison: neither tag may start with W/. If-None-Match uses weak comparison, matching the opaque values regardless of W/. Values remain case-sensitive. The * wildcard checks representation existence here, not a particular version.

Strong and weak ETag comparison serve different purposes
Current tagReceived tagStrong comparisonWeak comparison
"v1""v1"MatchesMatches
"v1"W/"v1"Does not matchMatches
W/"v1"W/"v1"Does not matchMatches
"v1""v2"Does not matchDoes not match
"v1""V1"Does not matchDoes not match

Simulate an HTTP decision without contacting a server

The six parameters yield 432 combinations. Requiring a conditional field and selecting 204 for successful PUT are policies of this fictional scenario. Requiring any condition does not prevent every lost update: If-Match: * compares no version.

Model decision : 304

304: If-None-Match finds a weak match for GET or HEAD. Reuse the stored representation under cache rules with the revalidation metadata.

304 and 204: no response content.

Request excerpt

GET /demo/resource HTTP/1.1
Host: api.example.test
If-None-Match: W/"v1"

Response excerpt

HTTP/1.1 304 Not Modified
Date: Thu, 22 Oct 2026 00:00:00 GMT
ETag: "v1"
Cache-Control: private, no-cache

Fictional HTTP/1.1 excerpts for reading: bodies are omitted even where allowed. api.example.test is an example domain. The date is fixed. This model does not update the ETag after PUT; the separate walkthrough follows successive versions.

Ten reproducible situations

Ten reproducible situations
Fictional situationCondition and expected outcomeInterpretation
Read using a weak tagGET · "v1"
If-None-Match: W/"v1" → 304

Access allowed · Conditional field optional

W/"v1" and "v1" match weakly.
Different client versionGET · "v1"
If-None-Match: "v2" → 200

Access allowed · Conditional field optional

The client needs the selected representation.
HEAD revalidationHEAD · "v1"
If-None-Match: "v1" → 304

Access allowed · Conditional field optional

The status can be 304; the response has no content.
Write based on an old versionPUT · "v2"
If-Match: "v1" → 412

Access allowed · Conditional field optional

Read again and resolve the conflict before retrying.
Weak tag with If-MatchPUT · "v1"
If-Match: W/"v1" → 412

Access allowed · Conditional field optional

Strong comparison rejects a weak tag.
Required condition absent on PUTPUT · "v1"
none → 428

Access allowed · Conditional field required

428 follows the policy announced by this API.
Access denied despite matching tagGET · "v1"
If-None-Match: "v1" → 403

Access denied · Conditional field optional

Authorisation precedes HTTP conditions.
Write on the correct versionPUT · "v1"
If-Match: "v1" → 204

Access allowed · Conditional field required

The model accepts PUT and selects a 204 success.
If-None-Match: * on existing dataPUT · "v1"
If-None-Match: * → 412

Access allowed · Conditional field optional

The wildcard matches any existing representation.
If-Match: * on existing dataPUT · W/"v1"
If-Match: * → 204

Access allowed · Conditional field required

The wildcard passes even with a weak current tag: it does not protect a version.

Four rules for a personalised response

Four rules for a personalised response
Response fieldHTTP effect within this scopeEvidence to retain
Cache-Control: no-cacheUnqualified no-cache permits storage, but any reuse needs successful validation with the origin server.Observe a conditional round trip; do not read no-cache as a storage prohibition.
Cache-Control: no-storeForbids storage by private and shared HTTP caches. It is not a general privacy guarantee.Also review logs, history, screenshots and application storage.
Cache-Control: privateUnqualified private forbids storage by a shared cache; a private cache may store under the other constraints.Distinguish browser, proxy and CDN. A directive does not replace access checks.
VaryAdds the named request fields to selection of a stored response. It does not decide who may access a resource.Test relevant variants. Do not assume a cookie or Authorization automatically prevents all caching.

Useful API acceptance evidence

  • Expected request and status: method, test resource, access rights, conditional field and current ETag. Use fictional data and remove secrets.
  • Observed response: status, ETag, Date, Cache-Control, Vary and no content for HEAD, 204 or 304. A 304 must carry the required metadata that would have accompanied the 200.
  • Concurrency: verify that a stale write fails without changing the resource; retain the conflict-resolution decision. Do not blindly replace the ETag and resend the same write.

Follow the two-client conflict →

Primary references and limits

The standards define HTTP conditions and caching. The ten cases, laboratory and two-client walkthrough are original illustrations. Displayed results are calculated by this local model, not measurements of this site or your infrastructure.

References reviewed

공식 참조

참조는 방법을 뒷받침합니다. 상황에 맞게 검사를 조정하십시오. 이는 인증이 아닙니다. 원본 참조 제목 및 소스 문서는 다른 언어로 작성되었을 수 있습니다.

참고 자료 확인일 .