Cache reserve and purges

We want to be able to tell Cache reserve to purge a given resource and re fetch it from its origin.

  1. Can this be done with a single PURGE request, or do we need to send a subsequent GET request as well?
  2. Are PURGE requests atomic? I.e. if we do a PURGE request and an immediate subsequent GET request, will Cloudflare have already purged the item from the PURGE request or might it just serve back the old cached page?

Thank you

Hi @dylan.jennings,

Please check this documentation for Cache Reserve.

  1. Can this be done with a single PURGE request, or do we need to send a subsequent GET request as well?

PURGE is a valid operation. The resource will be purged from Cache Reserve. Subsequently accessing the cacheable resource will store it on Cache Reserve. This action is not controllable explicitly. Caching will occur as normal.

  1. Are PURGE requests atomic? I.e. if we do a PURGE request and an immediate subsequent GET request, will Cloudflare have already purged the item from the PURGE request or might it just serve back the old cached page?

PURGE requests are immediate, but take time to propagate globally. There may be some delay and the old resource may be served from Edge/Cache Reserve until the purge request hits. Edge is definitely faster than Cache Reserve though.

This may take anything from 10 minutes minimum to 30 minutes maximum depending on many factors eg: Edge colo loads.

Thank you.

I want to be able to tell Cache reserve to purge a given resource and re fetch it from its origin. How do you suggest I go about doing this?

Hi @dylan.jennings,

As highlighted earlier, you can tell Cache Reserve to purge a resource.

You cannot tell Cache Reserve to cache a resource.
That is not controllable. Cache Reserve will cache resources automatically.

This is not available for Cache Reserve.

You can only control all resources’ caching behaviour. Via cache control headers or Page Rules (Edge Cache TTL). When does the resource get cached, depends on various factors.

I hope this clarifies your question.
Thank you.

You cannot tell Cache Reserve to cache a resource.

I can’t see a cache product being very useful if you can’t tell it to cache something! :slight_smile:

After having a live chat with a support agent, they informed me that PURGE requests do not revalidate, they only delete. They also said that while there shouldn’t generally be a delay in purging, it may not be instantaneous in all cases.

We determined the correct logic in this case would be:

  • Send the PURGE request
  • Add a small delay before sending the subsequent GET request
  • Check the “Age” header in the response returned by Cloudflare. If the age is still high, then retry the GET request using an exponential backoff.

This should ensure that the page gets recached.