I am using workers in order to direct requests to my origin into 2 servers.
I direct to a first server, and if the file is not present I direct to another.
The problem is that file purge are now a problem with the API or UI.
what happens is that the request is being modified by the worker, in order to go to the first server, which has a different domain than my website.
And this is the url that is saved on Cloudflare edge server.
so when I try to purge the file, the url doesn’t match.
AND
I cannot use the real url to be purged because in the UI purge tool, you are only allowed to purge URL from within the domain name of your account.
I asked customer service to purge one for me and they comfirmed the problem
my only other solution is of course to purge all. which I have not tried but MAY work, but it is not really an option for my site as the traffic load generated by this command is very high.
I am using other CDNs, like fastly, and they handle this kind of multi-origin server seamlessly.
I hope the tech team can fix this.
PS: I cannot change the domain of my first server as it is google cloud servers url:
https://storage.googleapis.com/bucketname/…
PS2: see below the code I am using for my worker
addEventListener(“fetch”, event => {
event.respondWith(fetchAndModify(event.request));
});
async function fetchAndModify(request) {
console.log(“got a request:”, request);
const gcs_request = “https://storage.googleapis.com/bucketname/”+request.url;
console.log("trying on gcs: "+gcs_request);
let response = await fetch(gcs_request);
console.log(response.headers);
return response;
}