Purge Cloudflare cache from a worker's runtime using the request URL, while caching based on the request object

I have a Cloudflare Worker that caches requests based on the complete request object, as shown in the code snippet below:

caches.default.put(incomingRequest, response);

However, I’m interested in deleting cached responses using only the URL of the request, as I can generate the URL but not the complete request object. I have two questions:

  1. Is it possible to cache responses using the complete request object and delete them using only the URL from the request object?
  2. If it’s possible, how can I achieve this? I’ve attempted it, but it doesn’t seem to work. I suspect it might be related to the worker executing in a different data center for the delete request compared to the cache put request.

Could someone please help me understand if it’s feasible to delete by URL while caching by the complete request object in Cloudflare Workers?

I can verify that the PUT and DELETE requests were indeed carried out in separate data center(s), which might explain why I’m facing difficulties purging by URL. Could someone please validate my hypothesis to determine its feasibility?

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.