Skip to content

feat: allow forcing cache control header#2

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

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

Conversation

@albaad

@albaad albaad commented Oct 5, 2023

Copy link
Copy Markdown
  • 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.

@landrade

landrade commented Feb 24, 2024

Copy link
Copy Markdown
Owner

Hi @albaad,

Could you add an explanation of what this PR resolve in the description?

@albaad

albaad commented Sep 11, 2025

Copy link
Copy Markdown
Author

Hi @landrade,

I’ve updated the PR description with an explanation of what it resolves—sorry for the long delay! Let me know if you need anything else.

@aartal

aartal commented Sep 30, 2025

Copy link
Copy Markdown

Hi @landrade,

Just checking if there’s anything missing or something I can do to help move this forward. Happy to address any feedback or make further changes if needed.

Thanks for your time!

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.

3 participants