I have a webapp which might not change for a week or so,
but sometimes it has to change more then 5 times a day.
so in those busy days i need to invalidate the cache immediately.
the problem is getting content from a graphql endpoint that is hosted on another domain.
so i need to listen for change in that graphql endpoint and invalidate the cache depending on that.
You could use a short TTL and stale-while-revalidate if the origin supports it.
Otherwise you’d need to either not cache it or query it through another channel and call the Cloudflare API to purge the asset when the result changed.
Using Workers with the form of caching @cs-cf presented, an example Cache-Control header to use would look like newHeaders.set("Cache-Control", "stale-while-revalidate=61, max-age=60"); with max-age adjusted to suit your exact needs. Remember that max-age and stale-while-revalidate are in seconds.