Hi everyone,
Looking for guidance on Cache Tags with AWS S3 as the origin. We currently do purge by URL (over 1M URLs/week) and want to switch to tags to dramatically reduce the number of purge requests. On S3 we add user metadata, so instead of a Cache-Tag header we only see x-amz-meta-cache-tag (which seems typical for object stores: R2 also uses x-amz-meta-*, Azure Blob uses x-ms-meta-*).
The only working pattern we have in a Cloudflare Worker is:
const tags = parse(head.headers.get('x-amz-meta-cache-tag') || '');
const resp = await fetch(s3Url, { cf: { cacheTags: tags, cacheEverything: true } });
return resp;```
Questions:
1. Is this the “right” approach for S3→Cloudflare (first `HEAD`, then `GET` with cf.cacheTags) or is there a way to do it with one request?
2. Is there any “pre-cache” hook/pattern to apply tags read from the origin response without an extra `HEAD`, i.e., at the moment of writing to cache?
3. We considered Snippets, but from the docs it looks like they won’t help: Snippets run outside the caching moment and can’t assign tags (cf.cacheTags isn’t available there; adding/renaming a header after caching won’t attach tags to the object). Is that understanding correct?
Thanks!