Skip to content

feat: allow forcing cache control header#1

Open
albaad wants to merge 1 commit into
mainfrom
feat/context
Open

feat: allow forcing cache control header#1
albaad wants to merge 1 commit into
mainfrom
feat/context

Conversation

@albaad

@albaad albaad commented Oct 5, 2023

Copy link
Copy Markdown
Owner
  • What it solves: Adds the ability to explicitly enable Cache-Control headers even when GraphQL responses contain errors. This is useful for scenarios where certain error outcomes should be cacheable (e.g., 400/404 for missing or not-yet-available resources), allowing downstream caches/CDNs to respect custom max-age and scope.
  • How: Introduces a helper cache.ContextWithForceCacheControl(ctx, true) that marks a request as eligible for Cache-Control header emission even when errors are present. The middleware uses this signal to compute and write the header from existing cache hints.
  • Why: Some APIs benefit from caching specific error responses to reduce load and improve latency, particularly for predictable cases like resource not found or not ready yet.
  • Docs: README updated with example usage showing how to enable forced cache control on error cases.

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.

1 participant