Flush Cache through response headers

Currently the only way to flush the cache within Cloudflare programatically is to use the API. This fequires additional steps in order to configure an API key / permissions etc.

It would be great if you could flush the cache through the output of headers. e.g. when someone saves a page within a CMS:

  1. Admin user edits a CMS page within the admin area

  2. Upon successful submission, output headers from the CMS:

X-Cloudflare-Cache-Purge: /homepage, /products, /products/*

  1. When Cloudflare sees this header, it should do 2 things:
    • Clear the cache for the URI’s in the response output
    • Remove the headers so they are not visible to the end user

By the time Cloudflare sees the header, it’s too late. The object in cache has expired, so they have looked to the Origin to get the new file, and will put that new version in the Cache.

And how different are the “additional steps to configure an API key” to the steps required to add the new header in the CMS? What happens if that header is on URLs in both /homepage and /products?

You would probably be better off using cache tags. Like caching by prefix (such as /products/*), these are only available on Enterprise plans, but you can purge related groups of files with a single cache request.

No, this isn’t about clearing the cache for the current page. It is about clearing the cache for other pages.

It means that a common content management systems can build logic into their platforms to clear Cloudflare caches without having to have users configure API keys.