feat: add android-sdk caching strategy#285
Conversation
5a2477a to
049e089
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 049e089370
ℹ️ 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".
| if strings.HasSuffix(r.URL.Path, ".xml") { | ||
| return s.config.FeedTTL | ||
| } | ||
| return 0 |
There was a problem hiding this comment.
Use explicit nonzero TTL for immutable Android SDK files
Returning 0 here does not produce permanent caching in this codebase: all current cache backends coerce ttl == 0 to their configured MaxTTL (for example in internal/cache/memory.go, internal/cache/disk.go, and internal/cache/s3.go). That means non-XML Android SDK artifacts will still expire (often after 1 hour) and be re-fetched, so the new strategy does not deliver the intended immutable-archive behavior.
Useful? React with 👍 / 👎.
Add a dedicated Android SDK caching strategy that handles the Android SDK
protocol where XML feed/manifest files are mutable and require short TTLs,
while archive downloads (.zip files) are immutable and can be cached
permanently.
The existing proxy strategy does not distinguish between these different
cache characteristics, so a dedicated strategy is needed to properly cache
SDK feeds with configurable TTLs while permanently caching archives.
The strategy:
- Routes requests through /android-sdk/{host}/{path...}
- Reconstructs the original HTTPS URL and proxies the request
- Uses configurable FeedTTL (default 1h) for XML files
- Uses permanent caching (TTL=0) for archive files
- Follows the same handler.New builder pattern as other strategies
049e089 to
e53535e
Compare
alecthomas
left a comment
There was a problem hiding this comment.
I think this is 👍 for now, but longer term I'd like us to come up with a generalised/extensible way of expressing these kinds of caching strategies. There's nothing that special about this that should necessitate native code, so it should just be configurable through the HCL somehow.
But LGTM for now!
Add a dedicated Android SDK caching strategy that properly handles the Android SDK protocol requirements.
The Android SDK protocol uses XML for all mutable manifests and .zip files for all immutable versioned archives. These have fundamentally different caching requirements:
The existing proxy strategy cannot distinguish between these two types of content and caches everything with the same TTL, making it unsuitable for Android SDK caching.
The new strategy:
/android-sdk/{host}/{path...}FeedTTLconfig (default 1h) for XML files (mutable feeds)Configuration in cachew.hcl:
The
feed-ttlparameter is optional and defaults to 1 hour.