Cart block now safe with page caching

Drupal offers page caching to help your site perform better with heavy traffic. Anonymous users (i.e. users who aren't logged in) will be served cached versions of pages straight from the database without any dynamic content generation depending on your settings. In Ubercart 1.x, this presented a problem, because the cart block would get cached at awkward times for anonymous users. If someone visited a page that was cached when someone else visited the page with products in their shopping cart, then it would appear on that page as if the customer actually had something in their cart. I call this "ghost" items, and it was a continual problem in Ubercart 1.x.

To try and mitigate this, we originally thought we just needed to clear Drupal's page cache when something happened to affect shopping carts. This produced the undesired side effect of rendering page caching useless. The cache would get cleared so often that any performance gains from having caching turned out were negated.

Ubercart 2.x now has a significantly reworked shopping cart block that is safe for caching. It does this by detecting your caching settings and the logged in status of the current user. If it sees that the user is not logged in and caching is turned on, it displays a trimmed down shopping cart block that just uses static HTML. If I'm not mistaken, a module like the AJAX Cart module should be able to add Javascript to the page that would display the dynamic cart block for those interested.

The cart block has also been completely reworked to be easier to theme. Thanks to stepthegeek and others for reviewing patches and providing ideas to make it a much easier job.