Skip to content

[#55] HTTP validator 기반 GET 응답 재검증을 구성한다 - #61

Merged
opficdev merged 7 commits into
developfrom
feat/#55
Aug 23, 2026
Merged

opficdev merged 7 commits into
developfrom
feat/#55

Conversation

@opficdev

@opficdev opficdev commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

🔗 연관된 이슈

📝 작업 내용

📌 요약

  • ETag, Last-Modified, 빈 304 Not Modified를 사용하는 opt-in memory cache 재검증 경로 추가
  • 기존 .memory(ttl:) 동작과 cache·진행 중 동일 요청 병합 계약 유지
  • NXAPIClient 인스턴스별 cache 생명주기와 값 복사 공유 규칙 문서화

🔍 상세

  • NXCache.revalidatingMemory(ttl:) 추가
    • private·비인증·본문 없는 GET만 대상
    • 만료된 200 응답에 ETag 또는 Last-Modified가 있을 때만 조건부 요청 수행
    • .memory(ttl:), validator 없는 200, 201·204 등 200 외 성공 응답은 기존 TTL 만료 뒤 무조건 요청 경로 유지
  • cache key를 If-None-Match, If-Modified-Since 추가 전에 생성해 기존 key 계약 유지
  • 일치하는 validator와 빈 본문의 304 수신 시 cached body와 갱신 헤더를 결합한 200 반환
    • ETag와 Last-Modified가 함께 있으면 ETag 우선
    • 불일치 validator 또는 본문이 있는 304는 stale response 폐기 후 기존 응답 검증 경로 진행
  • NXResponseCacheStore actor가 만료 응답의 validator와 재검증 Task를 보관해, 동일 stale GET 다섯 건의 transport 요청을 한 건으로 병합
  • NXAPIClient(configuration:)마다 독립 cache·진행 중 요청 store 생성
    • 서비스 또는 의존성 컨테이너에서 같은 client 재사용 시 cache 상태 공유
    • 같은 client 값의 복사본은 기존 store 공유
  • README·README.ko·DocC에 정책 선택, client 생명주기, exhaustive switch 재컴파일 영향 안내 추가

검증

  • swift build 성공
  • swift test 성공 — 98개 테스트, 22개 suite
  • swiftlint lint --strict Sources Tests — 위반 0건
  • git diff --check 성공
  • Designer·Architecture Watcher·Code Reviewer·Verification Runner 검수 통과

📸 영상 / 이미지 (Optional)

flowchart LR
    request["private·비인증·본문 없는 GET"] --> key["NXRequestCacheKey<br/>조건부 header 추가 이전"]
    key --> store["NXResponseCacheStore<br/>cache · 진행 중 요청"]
    store --> ttl{"TTL 유효?"}

    ttl -->|예| cached["cached response"]
    cached --> pipeline["NXResponsePipeline"]

    ttl -->|기존: 만료된 모든 응답| reload["무조건 GET"]
    ttl -->|현재 .revalidatingMemory: 만료| eligible{"cached 200과<br/>ETag 또는 Last-Modified?"}
    eligible -->|아니오| reload
    eligible -->|예| conditional["If-None-Match<br/>If-Modified-Since"]

    conditional --> transport["NXHTTPTransport"]
    reload --> transport
    transport --> response{"응답"}

    response -->|200| replace["body·validator cache 갱신"]
    replace --> pipeline
    response -->|일치하는 빈 304| merged["cached body·갱신 header 결합<br/>200 응답"]
    merged --> pipeline
    response -->|불일치 또는 본문 304| discard["stale response 폐기"]
    discard --> pipeline

    linkStyle 5 stroke:#6b7280,stroke-width:2px,stroke-dasharray:8 5;
Loading

점선은 기존의 'TTL 만료 응답 전체를 무조건 요청'으로 연결하던 경로이며, 현재는 validator가 있는 cached 200에서만 조건부 요청 연결선으로 대체된 부분입니다.

@opficdev opficdev self-assigned this Aug 23, 2026
@opficdev opficdev changed the title Feat/#55 [#55] HTTP validator 기반 GET 응답 재검증을 구성한다 Aug 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cdfa2803a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/Runtime/NXResponseCacheInterceptor.swift
Comment thread Sources/Runtime/NXResponseCacheInterceptor.swift Outdated
@opficdev
opficdev merged commit db3ce0d into develop Aug 23, 2026
4 checks passed
@opficdev
opficdev deleted the feat/#55 branch August 23, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP validator 기반 GET 응답 재검증을 구성한다

1 participant