Caleb
Caleb
CDCloudflare Developers
Created by Caleb on 10/20/2024 in #general-help
Single file cache not working
I have been stuck on this for a long time. I cannot get the single file cache purge to work. My files are from an r2 bucket.
const clearCache = await axios.post(`https://api.cloudflare.com/client/v4/zones/${env.CLOUDFLARE_ZONE_ID}/purge_cache`, {
files: [https://my.customr2domain.com/filename],
}, {
headers : {
'X-Auth-Email': env.CLOUDFLARE_EMAIL,
'X-Auth-Key': env.CLOUDFLARE_GLOBAL_API_KEY,
'Content-Type': 'application/json'
}
})
.catch(e => console.log(e.response.data.errors[0]))
const clearCache = await axios.post(`https://api.cloudflare.com/client/v4/zones/${env.CLOUDFLARE_ZONE_ID}/purge_cache`, {
files: [https://my.customr2domain.com/filename],
}, {
headers : {
'X-Auth-Email': env.CLOUDFLARE_EMAIL,
'X-Auth-Key': env.CLOUDFLARE_GLOBAL_API_KEY,
'Content-Type': 'application/json'
}
})
.catch(e => console.log(e.response.data.errors[0]))
this simply does not work. When I purge on the cloudflare dashboard, it does not work. I have 0 custom transform rules in place. I have a single cache rule in place on the r2 custom domain. The cache header is always showing HIT unless I purge everything then it is EXPIRED and new content is served. What am I doing wrong? I've read the docs, read the community help pages, nothing is working. I have also asked 3 times in the r2 channel about this and no one from the Cloudflare team has said anything.
38 replies