Automatic emptying of cache after user logout

how to empty Cloudflare’s cache automatically after the user logs out of my site?

Your use case is a bit weird. If the content is user specific then it should probably not be cached in the first place. If the cache is not user specific, why would you want it to be cleared when one user logs out, causing poor performance for the next user?

In any case, you would have to have a function that uses the Cloudflare API (https://api.cloudflare.com/client/v4/zones/:zone_id/purge_cache) with an API Token. This should probably be done on the Origin side (or in a Cloudflare worker) to avoid exposing your Cloudflare API Token in the client.

2 Likes

2 posts were split to a new topic: Website Hacking

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