On basic commerce sites, the shopping cart is one of only few fragments on a page which are effectively different for every user. In such situations it is attractive to speed up a site by deploying some suitable page caching mechanism and load the cart-block using Ajax or ESI.

Currently commerce_cart.theme.css is only loaded if there are items in the shopping cart. This may lead to a cart appearing unstyled in the following situation:

  1. User A (shopping cart empty) triggers page miss, page will be saved to cache
  2. User B (items in shopping cart) hits the cached version, shopping cart CSS is missing

This problem can be solved easily by simply enforcing the shopping-cart CSS using a custom module. However I feel that it wouldn't hurt when commerce would play nice out of the box with advanced page caching strategies.

CommentFileSizeAuthor
#1 2146917-always-add-cart-css.patch693 bytesznerol

Comments

znerol’s picture

StatusFileSize
new693 bytes
znerol’s picture

Status: Active » Needs review
rszrama’s picture

Seems easy enough, but I'm curious - how is this page being served from cache if the second anonymous user has a product in the cart? In that case, the user would have a session and should be bypassing the page cache, no?

znerol’s picture

Authcache 7.x-2.x has support for delivering blocks, views and panels content panes using Ajax or ESI. It also supports delivering cached pages for anonymous users with an open session. See this tutorial for instructions on how to explore Authcache 2 with Commerce Kickstart 2.

rszrama’s picture

Status: Needs review » Fixed

Cool, thanks for the info. I'll go ahead and get the patch in - should have no performance impact at all, especially given CSS aggregation and stuff.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Status: Closed (fixed) » Needs work

The last submitted patch, 1: 2146917-always-add-cart-css.patch, failed testing.

rszrama’s picture

Status: Needs work » Closed (fixed)