Apply Cloudflare Auto-Minify for Worker requests that return R2 html, js, and png files
I've turned on auto-minify on cloudflare and cleared the cache, but I don't see Cloudflare applying any auto-minifying to my pages.
The flow currently is client request -> worker -> r2 file. It seems like this bypasses the Auto-Minify logic layer. Is there a way to enable this?
6 Replies
Auto minify only applies to cached assets, are you implementing the Cache API in the Worker?
I'm not. I'm getting the data from R2 and returning directly. Is there a way to do what you are talking about with R2?
Use the Cache API · Cloudflare R2 docs
Use the Cache API to store R2 objects in Cloudflare’s cache.
this is a free api to use, right?
Will this also work with the
Polish
feature?Yes and yes
Cache API is a way to programatically interact with the regular zone CDN cache, which is completely free