1

I'm having a bug with the Varnish Caching and after investigating and searching for a solution, I'm still not able to solve the problem.

The FPC is working fine most of the times, but sometimes the issue happens. We have some hidden catalog data (price for example) if the customer isn't logged in, that way we force a guest to register an account in order to view all the available data. However, sometimes after the login (especially if we login after opening some catalog page), the customer won't be able to see all the available data on that same page he was. If he switches to a sub category of that same catalog page, he can see all the data, but if he switches to the main category (the catalog page he was), the data is still hidden.

I know it has something to do with FPC/Varnish, but I haven't been able to find what he's causing this issue. I use the default Varnish Configuration File.

I think I'm also taking in consideration the user/customer's session cookie.

if (req.http.cookie ~ "X-Magento-Vary=") {
        hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
    }

EDIT: This happens if the customer logins via homepage, after opening some catalog page (and that catalog page it's the only one that's still hiding data)

4
  • how are you determining whether the user is logged in or not? not all methods work well with fpc.
    – paj
    Commented Feb 7, 2020 at 22:00
  • @paj I check if an user is logged in with the following: $isLoggedIn = $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); Commented Feb 10, 2020 at 15:48
  • Tiago, did you find a solution. I guess we are seeing something similar. Commented Dec 3, 2020 at 22:06
  • @AlexanderGran the only solution I've found is to make the customer's session longer, for example 30 days, things work smoothly that way Commented Dec 9, 2020 at 11:02

1 Answer 1

0

May be your catalog page doesn't update after login because it was also cached by the browser. Is it the same if you disable browser cache? (Developer Tools)

1
  • Even if I disable cache, it still happens. After lots of debugging and tests, I've found it's a problem with the X-Magento-Vary, sometimes the cookie doesn't get created. If it does, everything is fine, If it doesn't, user will lose session. Commented Feb 27, 2020 at 9:37

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.