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)

  • how are you determining whether the user is logged in or not? not all methods work well with fpc. – paj Feb 7 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); – Tiago Costa Feb 10 at 15:48
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)

| improve this answer | |
  • 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. – Tiago Costa Feb 27 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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