Skip to content

Performance & Caching ​

How recommendation blocks show up without slowing your store down, why they work behind a page cache, and what to check if something feels slow.

Recommendations are personal. They depend on the product being viewed, what's in the cart and what the shopper has already seen. Personal content and page caching usually don't get along. Here's how the plugin handles that, and what it means for you.

How a block gets onto the page ​

Every page load follows the same steps:

  1. Read the published settings. The plugin keeps one ready-to-use copy of everything the storefront needs, rebuilt each time you save in the admin. Unsaved edits are never read.
  2. Work out which slots could show something. A quick first check against the page itself, such as which page it is and which recommendations are placed there, decides which spots get a placeholder. Spots that can never show anything on this page get nothing.
  3. Send the page with placeholders. Each spot holds a placeholder sized like the real block. Shortcodes, editor blocks and hooked locations all work the same way.
  4. Fill everything with one request. Once the page loads, a single request asks the server for every block on the page at once. The Recommendation Manager runs once for the whole page, with the shopper's real session, and all the products are loaded in one batch.
  5. Report views and clicks. Small background requests record what was seen and clicked, without affecting your cache.

Why it works behind a page cache ​

Step 3 is the important one. What ends up in your cached page is only the placeholder. It holds nothing specific to any shopper, so it's safe to cache and safe to serve to everyone.

The real content arrives from one request afterwards. That means:

  • A cached page never shows one shopper another shopper's recommendations.
  • You don't need to exclude product or cart pages from your cache.
  • There's one request per page, not one per block. Four blocks on a page still make a single call.

Layout shift ​

A placeholder reserves the space the block will take, so content below it doesn't jump when the products arrive.

There's one exception. A recommendation that has a display condition (for example "only for returning visitors") gets a hidden placeholder that takes up no space. Most shoppers on that page won't meet the condition, and reserving space for all of them would leave a gap on most page views. For the shoppers who do meet it, the block appears and the content below moves down.

How much it adds to a page ​

FileSize
Storefront JavaScriptabout 4 KB (about 2 KB compressed)
Storefront CSSabout 3 KB, and it uses your theme's styles by default

More importantly, neither loads on a page with nothing to show. If no recommendation can appear on a page, the plugin adds no stylesheet, no script and no request to it. A store with recommendations only in the cart adds nothing to its product pages.

The editor block's script only loads in the block editor, never on the storefront.

What never happens while a shopper waits ​

  • Order mining. Every pass over your orders runs in the background through Action Scheduler, or from WP-CLI. See Store Statistics Pro.
  • Analytics totals. These are calculated in the background.
  • Rebuilding the published settings. That happens when you save in the admin, not when a shopper loads a page.

Things that affect performance ​

Catalogue size. Filters run as product searches, so a very large catalogue with a very broad filter costs more than a narrow one. Automatic filters are usually cheaper than a wide custom filter, because they're limited by the context.

Number of blocks per page. More blocks mean more products to look up and load. If you have several recommendations that can land on the same page, turning on Limit blocks per page in the Recommendation Manager keeps this in check, and it's off by default.

Object caching. It helps on larger catalogues, but it isn't required.

WP-Cron. The background jobs (analytics totals, clearing old data and, on Pro, order mining) are scheduled tasks. If your host turned off WP-Cron without setting up a real cron job instead, they never run: analytics stay empty and statistics never get mined. See Troubleshooting.

Working with caching and optimisation plugins ​

Usually there's nothing to set up. Two things to watch for:

Aggressive JavaScript deferral or "delay until user interaction" can stop the fill request from running, so the placeholders stay on the page. If blocks appear as grey placeholders that never fill in, exclude the plugin's storefront script from delay or deferral.

HTML minifiers that remove data- attributes break how the plugin finds its blocks and records views. It's rare, but it happens with the most aggressive settings.

If a block shows in a private window but not once your cache is warm, that's the clue: the cached placeholder is fine, and something is blocking the fill request.

What gets stored, and how it's cleaned up ​

DataHow long it's kept
Sales (conversions)Kept indefinitely, because it's your revenue record
Views, clicks, add-to-carts and held-back recordsDeleted after 90 days by a nightly job
Daily totalsKept. They're small, and they're what Analytics reads
Mined product pairs ProRebuilt from your orders, so never the only copy of anything

A shopper's session data is kept for 48 hours at most. The session itself, which the Recommendations per session limit counts within, ends after 30 minutes without activity.

Checking it yourself ​

  • Browser developer tools → Network. Load a product page with a recommendation and look for a request to /wp-json/sprcm/v1/hydrate. One is correct. On a page with no recommendations there should be none.
  • Lighthouse. Check Cumulative Layout Shift on a product page with a recommendation that has no display conditions. It shouldn't change.
  • Query Monitor. Products are loaded in one batch, so you should see one product lookup for the page, not one per block.

Next ​