Keep cache invalidations safe#185
Conversation
There was a problem hiding this comment.
Pull request overview
This PR ensures cache-tagged responses remain purgeable even when the set of tags would exceed Cloudflare’s documented Cache-Tag header value limits, by introducing an “overflow” fallback tag and stricter tag validation.
Changes:
- Add Cloudflare-compliant cache tag validation/minification logic via
StaticCacheTag. - Limit emitted
Cache-Tagvalues to Cloudflare’s 16KB aggregate header value limit and emit an{environmentId}:overflowfallback tag when truncation occurs. - Remove response header “normalization” (joining/truncation) from
ResponseEventHandler, shifting Cache-Tag safety intoStaticCache, and add unit tests covering overflow + tag validation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/StaticCacheTest.php | Adds tests asserting overflow tag emission + header length bounding, and that purges include the overflow tag. |
| tests/unit/StaticCacheTagTest.php | Adds unit coverage for tag validation rules and minified tag generation. |
| src/web/ResponseEventHandler.php | Removes header joining/truncation logic previously applied after response preparation. |
| src/StaticCacheTag.php | Reworks tag sanitization into explicit Cloudflare-validity checking; preserves valid tags and drops invalid ones. |
| src/StaticCache.php | Introduces Cloudflare Cache-Tag length limiting, overflow tag emission, and purge behavior that includes overflow fallback. |
| src/Module.php | Removes an outdated comment tied to the now-removed header normalization behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c38ce09937
ℹ️ 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".
Keeps cache-tagged responses within Cloudflare's limits while preserving invalidation with the overflow tag.
The Gateway purges the overflow tag with every cache-tag purge. Overflow fallback is logged at info level because invalidation remains safe.