Features

Cache WooCommerce Shortcodes

Published · Last updated

Product grid shortcodes are convenient, but they’re expensive. The [sale_products], [best_selling_products] and Flatsome [ux_products] shortcodes each run a product query and render a grid every single time a page containing them is loaded. On a small catalogue you won’t notice. On a large store, where each of those queries has to sift through thousands of products, the same work gets repeated on every page view even though the result barely changes from one visitor to the next.

The waste is that the output is almost always identical. A “best selling products” grid doesn’t change between two visitors a second apart, yet WordPress rebuilds it from scratch for both.

The fix is in the Bloat tab. Scalability Pro provides cached versions of these three shortcodes. When one runs, its rendered output is stored, and on subsequent page loads that stored output is served straight from cache instead of running the product query and rebuilding the grid. You enable caching per shortcode, so you can cache the ones that appear on your busiest pages and leave the others alone if you prefer.

Best for
  • Homepages and landing pages that show a “best selling” or “on sale” grid to every visitor
  • Category or shop templates where the same grid renders on high-traffic pages
  • Any page where the shortcode output is effectively the same for everyone

Because the grid is served from cache, the pages these shortcodes sit on stop carrying the cost of a live product query on every load, which is exactly where large stores tend to feel the strain.

Note

The cached grid updates on its own schedule rather than the instant a product changes, so there can be a short delay before a new sale price or a change in best-sellers shows up. That trade-off is fine for a “best selling” or “sale” grid, which does not need to be second-accurate, but keep it in mind for any grid you expect to reflect stock or price changes immediately.

The product query behind these grids is the same kind of query that Custom Query Alterations can optimise elsewhere on the site, and the Bloat tab it lives in also holds the Remove WooCommerce Dashboard Bloat options.

In short: [sale_products], [best_selling_products] and Flatsome’s [ux_products] rerun a product query on every page load. The Bloat tab lets you switch on cached versions per shortcode, so the grid is built once and served from cache after that, keeping those pages fast on big catalogues.

Further reading

cut the cost of the individual pages those grids link to
optimise the product queries that other shortcodes and widgets run
more of what the Bloat tab can switch off

Comments

▲
▼
1/1