lsretailomni / lsmag-two

LS Ecommerce - Magento, an ecommerce interface for integrating Magento with LS Central.
https://www.lsretail.com/
10 stars 16 forks source link

Cache context contains customer id making page cache unique for each customer #47

Closed xcom-magento closed 1 year ago

xcom-magento commented 1 year ago

Customer id and customer e-mail are added to the HttpContext in Ls\Omni\Plugin\App\Action\Context::aroundDispatch. This causes each customer to have an own page cache built for the entire webshop making page load time slower as they should be.

The values stored in the HttpContext object are loaded later on requests that not seem to be cached. In places like this you can just use the customerSession object (\Magento\Customer\Model\Session) to load this data like you already do when adding the data to the HttpContext object. Since this data is loaded asychronous or in the cart using this methods seems to be redundant.

Preconditions (*)

  1. Magento 2.4.x
  2. lsretail/lsmag-two 2.3.0
  3. Enable Varnish

Steps to reproduce (*)

  1. Login as customer, load random page the is stored in page cache
  2. Refresh page
  3. Login as other customer in same customer group with same currency
  4. Visit the same page

Expected result (*)

  1. Page should be loaded from Varnish giving a 50ms like response

Actual result (*)

  1. The page cache for new customer is not prewarmed and page speed (ttfb) is not a fast as it should be.
umarusaf902 commented 1 year ago

Hi @xcom-magento, thanks for reporting this. This issue has already been addressed and is available in the master branch and will be added in our next release.