1

I have a module that tracks users engagement in magento. This module inserts the user data inside the HTML.

The problem is: some of my clients are using full page cache and the user data are cached in the HTML. If you log in a cached page, you will get the wrong user data.

To fix this, i was thinking if i could get the user data from a AJAX request. But i cant find the endpoint to do this.

Can someone help me with this?

Thanks.

1

What you're looking for is applyWithApp meaning you need to evaluate a block and fill in the gap in the Full Page Cache version of the page before returning it.

This gets tricky because you only have access to limited data, and config generally is not loaded at this point in Magento FPC lifecycle.

Usually you would test if a customer is logged in by:

  1. Register a new Pagecache Model which extends from Enterprise_PageCache_Model_Container_Customer
  2. in the function _getIdentifier you set a cache ID for values of customer + customer logged in value. See Enterprise_PageCache_Model_Container_Accountlinks for examples. As another aside cookie values are evaluated and can be obtained e.g. $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER_LOGGED_IN, '');
  3. Render the block in the _renderBlock method. Again, see Enterprise_PageCache_Model_Container_Accountlinks for relevant example.

Hope that helps!

0

I had a similar problem few months back. What I ended up was a similar solution the guy describes here better visitor log.

Basically you have to prepare controller to execute some action and call it somewhere on your page as AJAX request.

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.