• Resolved somePaulo

    (@finomeno)


    Hi!

    I’m using the Cookie and Content Security Policy plugin, and I have set Super Page Cache to bypass cache for pages that have the cookies_and_content_security_policy cookie set. In Firefox and Safari when I open any page of the site with cookies and cache cleared, the page cache status is DYNAMIC, and after accepting all cookies the cookie above is set, the page gets reloaded as DYNAMIC again and pulls all the initially blocked scripts.

    In Chrome however, a weird thing happens. Whichever page of the site is the first one I open in a clean browser session, it gets loaded as DYNAMIC at first, but when the cookie above is set with the preferences accepting all cookies, the page gets reloaded with cache status HIT and keeps blocking the supposedly allowed scripts. Going to any other page on the site works correctly, the cookie is respected by the browser, the cache status is DYNAMIC, and all scripts load just fine.

    Going back in history to the initial page doesn’t change anything. Going to that page from the site menu (forward in browser history) doesn’t change anything. Clearing the browser cache and hard refreshing the page doesn’t change anything. A simple refresh after at least 20 minutes (didn’t time it, just refreshed, and it worked) makes the page work as intended.

    My cache lifetime settings are set to the default values that came with Super Page Cache – 31536000 for CloudFlare and 60 for browser. If I understand correctly and those are seconds, then it shouldn’t be related to my problem. Tried changing the browser value to 20, but that didn’t change anything either.

    I’m at a loss here. Am I doing something wrong? Is it Chrome? Or the other way around – Firefox and Safari are doing something that makes it work when it shouldn’t? Please help.

    • This topic was modified 1 year, 1 month ago by somePaulo.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    Cloudflare won’t cache a page with set-cookie in the response header. So, maybe when yoiu are loading the page for the first time, the set-cookie is there and hence you see DYNAMIC. But on the next loads that set-cookie response header is not there and as a result you are seeing cached pages.

    I would suggest you to try the new cache rules: https://gist.github.com/isaumya/af10e4855ac83156cc210b7148135fa2 which you can use to bypass cache based on cookie in a more effective manner.

    Thread Starter somePaulo

    (@finomeno)

    Hi!
    Thanks for the suggestion.

    I changed the CLoudflareCache configs to use the new cache rules, included the cookies_and_content_security_policy cookie in there, disabled workers mode, and it sort of woks, but still with a weird quirk on Chrome based browsers only.

    So, currently, on first load, the cache status is EXPIRED, and after accepting cookies the page gets reloaded as DYNAMIC in Firefox, and everything works. In Chrome & Co., however, accepting the cookies reloads the page as EXPIRED again, still blocking scripts, but hitting the reload button straight after that automatic reload makes things work, loading the page as DYNAMIC with all the necessary scripts.

    Enabling the Overwrite the cache-control header option doesn’t change anything. I’ve tried waiting a minute before accepting cookies, but that didn’t help either. Only a browser reload fixes things on Chrome. I wonder if there’s a particular parameter the cookies plugin could pass to force a proper reload…

    Also, the cache rules instructions mention removing the cache buster query parameter, but I don’t have that anywhere in my plugin settings.

    • This reply was modified 1 year ago by somePaulo. Reason: More details
    Thread Starter somePaulo

    (@finomeno)

    The option for removing the cache buster query parameter appeared after a re-login. Did that. Flushed all caches. Chrome still misbehaves.

    Plugin Contributor iSaumya

    (@isaumya)

    Hi worker mode is enabled you won’t see the remove cache buster query param option.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bypassing cache for cookie not working in Chrome and clones’ is closed to new replies.