Create helix-shared-edge-cache for unified cache APIs
- Dominant language
- JavaScript
- Stars
- 15
- Forks
- 16
- Avg merge
- 23h 18m
- Merged PRs (30d)
- 14
Description
Unified cache API adapter for Fastly Compute and Cloudflare Workers platforms.
## Background
Per [PR #77](https://github.com/adobe/helix-deploy-plugin-edge/pull/77) and [comment](https://github.com/adobe/helix-deploy-plugin-edge/pull/77#issuecomment-3554569809), we need unified cache APIs that abstract platform differences between Fastly's SimpleCache and Cloudflare's Cache API.
## Requirements
### Core Interface
```javascript
interface EdgeCache {
get(key: string): Promise;
getOrSet(key: string, fetchFn: () => Promise, ttl: number): Promise;
purge(key: string): Promise;
}
```
### Platform Mappings
**Fastly**
- Use `fastly:cache` (SimpleCache)
- `getOrSet()` maps to `SimpleCache.getOrSet(key, async () => ({ value, ttl }))`
- `purge()` uses `SimpleCache.purge(key, { scope: 'global' })`
**Cloudflare**
- Use Cache API (`caches.default`)
- `getOrSet()` wraps `cache.match()` + `cache.put()` pattern
- TTL controlled via Cache-Control headers (`s-maxage=${ttl}`)
- `purge()` uses `cache.delete()`
### Key Differences
1. **Cache semantics**: Fastly uses key-value, Cloudflare uses Request/Response pairs
2. **TTL handling**: Fastly explicit, Cloudflare via headers
3. **Scope**: Fastly supports global purge, Cloudflare is data-center local
## Implementation
Create `packages/helix-shared-edge-cache` following existing helix-shared package structure.
See [cache-storage.md](https://github.com/adobe/helix-deploy-plugin-edge/blob/compat/docs/api-unification/cache-storage.md) for detailed analysis and adapter patterns.
## Related
Part of edge unification effort alongside:
- helix-shared-edge-kv
- helix-shared-edge-geo
- helix-shared-edge-ratelimit
Contributor guide
Research direction
Start by reading docs/api-unification/cache-storage.md and the existing packages/helix-shared package structure. Define the package around the stated EdgeCache interface and implement the Fastly SimpleCache and Cloudflare Cache API mappings described in the issue. Done means the new package provides get, getOrSet, and purge with the specified TTL and purge behavior on both platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100