-
Notifications
You must be signed in to change notification settings - Fork 0
feat: export CacheOverride API for cross-platform cache control #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
This PR will trigger a minor release when merged. |
7bdd216 to
05195ce
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Implements a unified CacheOverride class that provides consistent cache
control across Fastly Compute and Cloudflare Workers platforms.
Features:
- CacheOverride class with mode-based configuration ("none", "pass", "override")
- Cross-platform compatible options only (ttl, cacheKey, surrogateKey)
- Platform-specific implementations:
- Fastly: Dynamically imports and uses native fastly:cache-override module
- Cloudflare: Maps to cf object options (cacheTtl, cacheKey, cacheTags)
- Wrapped fetch function that handles cacheOverride option
- Validation and warnings for unsupported platform-specific options
Design principles:
- Only includes options that work on BOTH platforms to maximize compatibility
- Platform-specific options (swr, pci, beforeSend, afterSend) are excluded
- Uses dynamic import for Fastly module to avoid errors on other platforms
- Lazy initialization of native CacheOverride for async module loading
Breaking changes: None - this is a new export added to the existing API
Closes #82
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Lars Trieloff <lars@trieloff.net>
96bb313 to
f2e471c
Compare
Adds a comprehensive demo fixture that showcases the CacheOverride API with real caching scenarios using httpbin as a backend. Routes: - /cache-demo/long - Long cache (1 hour TTL) - /cache-demo/short - Short cache (10 seconds TTL) - /cache-demo/no-cache - No caching (pass mode) - /cache-demo/custom - Custom cache key based on User-Agent - /cache-demo/ - Info page The demo uses httpbin.org/uuid to demonstrate cache hits vs misses, making it easy to verify caching behavior in real deployments. Signed-off-by: Lars Trieloff <lars@trieloff.net>
5446275 to
cbe92e7
Compare
Signed-off-by: Lars Trieloff <lars@trieloff.net>
Adds comprehensive integration tests that deploy and test the cache-demo fixture on both Fastly Compute@Edge and Cloudflare Workers, following the pattern established in existing integration tests. The tests verify: - Deployment to Fastly Compute@Edge with service ID - Deployment response contains expected API routes - Build process creates proper bundle - Cache-demo fixture integrates with helix-deploy CLI Refs #82 Signed-off-by: Lars Trieloff <lars@trieloff.net>
- Remove --update-package flag that was causing deployment errors - Fix bundle path from dist/default to dist/helix-services - Align with package.json wsk.package.name configuration Refs #82 Signed-off-by: Lars Trieloff <lars@trieloff.net>
Use root path for testing to avoid routing issues with nested paths. The info page should respond to any path that doesn't match specific cache routes. Refs #82 Signed-off-by: Lars Trieloff <lars@trieloff.net>
trieloff
commented
Nov 20, 2025
Contributor
Author
trieloff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't skip
Remove skip flag to test cache-demo deployment on Cloudflare Workers. This verifies the CacheOverride API works correctly on Cloudflare. Refs #82 Signed-off-by: Lars Trieloff <lars@trieloff.net>
Contributor
Author
|
depends on #88 for integration tests to run on cloudflare |
Expands edge-action with three new routes for testing CacheOverride API: - /cache-override-ttl - Tests TTL override functionality - /cache-override-pass - Tests pass mode (no caching) - /cache-override-key - Tests custom cache key Removes cache-demo fixture and tests to avoid Fastly service ID conflicts. Both cache-demo and computeatedge were deploying to service 1yv1Wl7NQCFmNBkW4L8htc, causing deployments to overwrite each other and resulting in 404 errors. Refs #82 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Lars Trieloff <lars@trieloff.net>
Instead of deploying the edge-action fixture 4 times (once for each test route), now deploy once and test all CacheOverride API routes with HTTP requests. This significantly speeds up the test suite by avoiding redundant deployments. The single test now: 1. Deploys edge-action with /201 test route 2. Makes HTTP requests to test CacheOverride routes: - /cache-override-ttl - /cache-override-pass - /cache-override-key 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Lars Trieloff <lars@trieloff.net>
Removes unnecessary execa dependency by using Node's native fetch API for testing CacheOverride routes. Node 18+ (project uses Node 24) has built-in fetch support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Lars Trieloff <lars@trieloff.net>
tripodsan
reviewed
Nov 25, 2025
tripodsan
reviewed
Nov 25, 2025
…Fastly API compatibility - Keep constructor overloading for compatibility with native Fastly CacheOverride API - Simplify export pattern with both default and named exports for flexibility - Fix circular reference issue with fetch export - All tests passing (32 tests, 76% coverage on CacheOverride) Addresses @tripodsan's review comments on constructor complexity and export patterns. Signed-off-by: Lars Trieloff <lars@trieloff.net>
tripodsan
approved these changes
Nov 26, 2025
trieloff
added a commit
that referenced
this pull request
Nov 26, 2025
feat: export CacheOverride API for cross-platform cache control
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #82 by exporting a unified
CacheOverrideAPI from the@adobe/fetchpolyfill that provides cross-platform cache control for both Fastly Compute and Cloudflare Workers.Design Principle: Only includes options that work on BOTH platforms to maximize cross-platform compatibility.
Changes
CacheOverride Class: New unified class supporting three modes:
"none": Respect origin cache control headers"pass": Prevent caching regardless of origin headers"override": Apply custom cache settingsCross-Platform Options Only:
ttl: Time-to-live in secondscacheKey: Custom cache keysurrogateKey: Surrogate keys for cache purgingPlatform-Specific Implementation:
fastly:cache-overridemodule using async initializationcfobject options (cacheTtl,cacheKey,cacheTags)Fetch Wrapper: Enhanced async fetch function that accepts
cacheOverrideoptionValidation: Warns users if they pass platform-specific options (like
swr,pci,beforeSend,afterSend) which are intentionally excluded for cross-platform compatibilityPlatform Mapping
"pass"cf.cacheTtl = 0"none"ttlttlcf.cacheTtlcacheKeycacheKeycf.cacheKeysurrogateKeysurrogateKeycf.cacheTags(array)Test Plan
Usage Example
Breaking Changes
None - this is a new export added to the existing API.
Notes
swr,pci,beforeSend,afterSend) are intentionally excluded to maintain true cross-platform compatibilityCloses #82
🤖 Generated with Claude Code