Closed scottmas closed 1 year ago
Theoretically modifying the object in R2 will update the last-modified
header and/or the etag
value, which will cause the user-agent/browser to refetch the object if they use the if-modified-since
, if-none-match
request headers. Are you seeing different results on your end?
To add, if you're referring to cached assets the Cache API will take regular cache purges for one-off invalidations of zones or URLs: https://developers.cloudflare.com/cache/how-to/purge-cache/
Or you can disable cache entirely by setting CACHE_CONTROL
to no-store
in render, which will also immediately stop serving from cache due to special handling of that value.
To be specific, I'm talking about the Cloudflare Cache API. Browser caching won't help us in this case. Nor should modifying the R2 objects since the Cloudflare Cache API will still think everything is unchanged unless I tell them about it. And the entire zone invalidation would work, but it's not as fine grained as I need. So I think the purge API is the best option like so
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
-H "X-Auth-Email: <EMAIL>" \
-H "X-Auth-Key: <API_KEY>" \
-H "Content-Type: application/json" \
--data '{"files":[{"url":"http://my.website.com/"}, {"url":"http://my.website.com/page_2"}]}'
I think the above is the answer. Or else appending some cache buster to the url I add to the cache API.
Thanks for all you do!
Hey there, this is a super well done library. Thank you!
I'm not sure if I'm missing something in your documentation or if it's just not possible, but how can I invalidate a url when the object at a R2 path changes? For example, when I'm updating the contents of my static website.