Lazy load the cart block

Created on 26 March 2025, 10 days ago

Describe your bug or feature request.

When the cart block is added to a region(typically the header), it introduces cache context based on the user, session, and cart.

This means every page that displays the cart block will become stale whenever the cart is modified, even though nothing actually changed on the page.

Similar to status messages and the add to cart form, we should lazy load the cart block. This would avoid unnecessary cache purging of pages, which is more scalable and performant.

MR to follow.

📌 Task
Status

Active

Version

3.0

Component

Cart

Created by

🇺🇸United States TomTech

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @TomTech
  • Pipeline finished with Success
    10 days ago
    Total: 720s
    #457986
  • Pipeline finished with Success
    10 days ago
    Total: 974s
    #458002
  • 🇺🇸United States TomTech
  • Pipeline finished with Success
    9 days ago
    Total: 598s
    #458264
  • 🇮🇱Israel jsacksick

    I prefer the second version better with the service as that allows overridding the logic easily.
    We might need a change record for that change though, other than that, perhaps I should test this manually as well, I just reviewed the code which looks ok at first glance.

  • 🇮🇱Israel jsacksick

    Also since CartBlock::getCartViews() is unused, it can be safely removed as it is not a public method.

  • Pipeline finished with Success
    8 days ago
    #459285
  • Pipeline finished with Success
    8 days ago
    Total: 7028s
    #459293
Production build 0.71.5 2024