How does Cache Purge API works?

I forcibly cached the API endpoints that are not very dynamic on one of my sites by writing a Cache Rule. I set the Edge TTL to 2 hours and the Browser TTL to disable. When I send the link of the endpoint I want to purge to Cache Purge, I get a successful response and when I go directly to the API endpoint, for example https://api.example.com/api/list, I can see the newly added or removed data with status code 200. When I refresh the page, it continues to fetch from the cache with code 304. But when I try to fetch this API endpoint from another domain, for example https://example.com, I still see the old data with status code 304. In short, when I access the endpoint directly, it is up-to-date, but when I fetch this endpoint from another domain, I see old data. Why this is happening and how can i solve this issue? 🤔
5 Replies
Lynx
Lynx•13mo ago
i guess nobody knows this mystery
Cyb3r-Jak3
Cyb3r-Jak3•13mo ago
That just clears it from Cloudflare’s cache so you should see a cf status of miss. It can still be cached by the browser
Lynx
Lynx•13mo ago
I set the browser TTL none. i just found something in cf's doc, leaving a screenshot right below. I will try sending the request with origin header including frontend's domain. I think by default cache purge request only effects the cached url's domain @Cyb3r-Jok3
No description
No description
Cyb3r-Jak3
Cyb3r-Jak3•13mo ago
What is the CF-Cache header in the response. Also 304 means not modified so it mean your client still has something cached
Lynx
Lynx•13mo ago
Thanks for help, it was just like i said before. Cloudflare storing caches based on the Origin request header, so if you have an API service, you need purge it on consumer domains as well by specifically adding the origins to request.
Want results from more Discord servers?
Add your server