If you’re looking for an alternative, check out Cloudflare’s new feature: https://developers.cloudflare.com/rules/snippets.
It lets you control your cache easily.
Try this snippet:
`javascript
const response = await fetch(request, {
cf: {
cacheEverything: true,
cacheKey: request.url,
cacheTtlByStatus: {
“200-299”: 604800, // Cache successful responses for 7 days
“404”: 1, // Cache not found responses for 1 second
“500-599”: 0 // Do not cache server errors
}
}
});
`
Using this method doesn’t add any extra charges. Workers could do the same, but they come with a per-request fee, which adds up.
Snippets aren’t free, but a basic paid plan gives you 10. One advanced snippet can replace multiple page-rules, making it a cost-effective solution.
However, this isn’t a solution if you were utilizing the free plan for many domains.
– Chad 😉