Purge cache of r2 object

Hello everyone :wave:

I think I’m doing something wrong but whatever i tried i can’t purge cache for the single file in r2 storage.

  • I’ve added custom domain for my r2 storage at cdn.sub.main.com.
  • Uploaded the file which is available at cdn.sub.main.com/file.js. Rewriting the same file with S3 API or manually in dashboard doesn’t clean its cache and still serves the old version.
  • tried to use purge cache API to purge cache for specified file passing https://cdn.sub.main.com/file.js doesn’t work. Same if i pass that file URL through cloudflare dashboard in Caching → Configuration → Custom purge. Cache stays there

It works only if i hit purge everything but its not an option for me.

So maybe there is a some specific URL for that file to purge its cache correctly or is there another option to do that?

Please help :blush:

I tried all possible ways during several hours, but for me works only if I send the next purge body via API:
see “developers(.)cloudflare(.)com/api/operations/zone-purge#purge-cached-content-by-url” (I don’t have permission to add links)

Good luck.

			"url": "https://files.site.com/file.js",
			"headers": {
				"Origin": "https://site.com"

If you use browser to GET data - don’t forget to disable browser cache, and add headers to request:

        headers: {
          'Cache-Control': 'no-cache, no-store, must-revalidate',
          'Pragma': 'no-cache',
          'Expires': '0',