Skip to content

feat: add android-sdk caching strategy#285

Open
joshfriend wants to merge 1 commit intomainfrom
feat/android-sdk-strategy
Open

feat: add android-sdk caching strategy#285
joshfriend wants to merge 1 commit intomainfrom
feat/android-sdk-strategy

Conversation

@joshfriend
Copy link
Copy Markdown
Contributor

@joshfriend joshfriend commented May 1, 2026

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:

  • XML feed files are mutable and should use short TTLs (configurable, default 1h)
  • Archive downloads are immutable and can be cached permanently (TTL=0)

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:

  • Routes requests through /android-sdk/{host}/{path...}
  • Reconstructs the original HTTPS URL and proxies the request
  • Uses the FeedTTL config (default 1h) for XML files (mutable feeds)
  • Uses permanent caching (TTL=0) for archive files (immutable archives)
  • Follows the same handler builder pattern as other strategies (e.g., hermit strategy)

Configuration in cachew.hcl:

strategy android-sdk {
  feed-ttl = "1h"
}

The feed-ttl parameter is optional and defaults to 1 hour.

@joshfriend joshfriend force-pushed the feat/android-sdk-strategy branch 3 times, most recently from 5a2477a to 049e089 Compare May 1, 2026 16:22
@joshfriend joshfriend marked this pull request as ready for review May 1, 2026 16:25
@joshfriend joshfriend requested a review from a team as a code owner May 1, 2026 16:25
@joshfriend joshfriend requested review from stuartwdouglas and removed request for a team May 1, 2026 16:25
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/strategy/android_sdk.go Outdated
Comment on lines +60 to +63
if strings.HasSuffix(r.URL.Path, ".xml") {
return s.config.FeedTTL
}
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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
@joshfriend joshfriend force-pushed the feat/android-sdk-strategy branch from 049e089 to e53535e Compare May 1, 2026 16:47
Copy link
Copy Markdown
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

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