0

Have been following this guide to make caching depend on the value of a specific cookie:

https://cornel.co/article/page-cache-cookiesor-anything-available-http-request-d9

However, it does not seem to work for anonymous users.

Debugging (xdebug) within both

src/StackMiddleware/CookiesPageCache.php

src/CookiesPageCacheServiceProvider.php

is possible when logged in as admin and running "cache rebuild" - but not when anonymous.

My question is - how should one go about debugging in the case of anonymous users?

5
  • 1
    You need two browser sessions, one logged-out for Xdebug and one logged-in to clear the cache (or use drush cr from the command line).
    – 4uk4
    May 31, 2022 at 14:40
  • Thanks for your response. I've done so, but xdebug is not triggered when running anonymous session which is what I need to work out why the caching is not working as hoped
    – user108001
    Jun 1, 2022 at 6:21
  • "drush cr" is not doing any difference in regards of triggering the debug for anonymous users.
    – user108001
    Jun 1, 2022 at 8:14
  • There is no question left to answer. Try different breakpoints, for example in index.php to see if XDebug is working. Look in the F12-tools of the browser to see the requests/response sent and received.
    – 4uk4
    Jun 1, 2022 at 9:21
  • Thank you, I seem to be moving on now
    – user108001
    Jun 1, 2022 at 11:29

1 Answer 1

1

I know this is over a year later, but the reason you're seeing this for anonymous users is very likely due to having the core Internal Page Cache module installed, which caches and serves the complete response to all anonymous users, and part of that response are the cookies. I know this because I went down my own rabbit hole, pulling out my proverbial hair trying to figure out why this was happening, which I documented in a GitHub issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.