Serve HTML cache when a value in cookie is set


I have implemented similar thing in my nginx server where it serves cached contents from html cache of the site (site is in php-fpm). The static html is only served when user is logged in. To check this i have added an extra simple cookie and added the check in nginx config.

Now I want to implement somthing similar in Cloudflare cache as well. All dynamic (html content) should serve from Cloudflare cache (if a particular cookie is not present).

I have checked the Cloudflare control panel but haven’t found anything that helps. So, I think I may have to use worker for that?

Please give me some hint or direction so I can get started! Have a great day!

Update: What I am trying to do is. Here is psudo code

if logged_in
    return and fetch from origin as usual
if ! logged_in

Hello there,

I’m not sure if I’m guiding you correctly. However, as far as I know Cloudflare offers custom caching with page rules. Whether it’ll be helpful or not? I can’t just tell. May I suggest you to look into the attached links.

For more, you can :search: the forum as well as check out Help center

I think it won’t serve the purpose since you are looking specifically for cookies.

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