CoreShop icon indicating copy to clipboard operation
CoreShop copied to clipboard

[Perf] allow some requests to not require loading the cart

Open dkarlovi opened this issue 2 years ago • 5 comments

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes

In 2.2.x, CoreShop\Bundle\CoreBundle\EventListener\RequestCartAvailability::checkCartAvailability will skip loading the cart in specific cases (like the route being _wdt, etc).

What would be useful here is to actually abstract this: allow developers to opt out of the cart requirement, meaning they could basically serve some requests without any database queries (if combined with #1803), this being an important property for very busy shops, for ESI fragments (Varnish) or requests which should be "realtime" (like search autocompletion).

dkarlovi avatar Nov 29 '21 17:11 dkarlovi

Any concrete ideas?

dpfaffenbauer avatar Mar 24 '22 08:03 dpfaffenbauer

@dpfaffenbauer yes: currently there are some items which are fetched in event listeners, regardless if they'll be required or not, this also applies to #1803.

We should instead aim to fetch / set those things just in time, as in if we know for sure they'll be required. Maybe we have some factory based magic for the cart? Meaning we only fetch it if the code requests it to begin with?

dkarlovi avatar Mar 24 '22 12:03 dkarlovi

CartAvailability could be replaced with a change in the CartContext for example.

dpfaffenbauer avatar Mar 24 '22 13:03 dpfaffenbauer

Yes, this could be done in general for other listeners too. Generally, any expensive operation should be done after an (implicit or explicit) opt-in, not opt-out.

dkarlovi avatar Mar 24 '22 14:03 dkarlovi

Note, this also applies to \CoreShop\Bundle\CoreBundle\EventListener\RequestCartRecalculation::checkPriceRuleState

dkarlovi avatar Oct 28 '22 10:10 dkarlovi