Why caching needs configuring
A page cache stores a finished HTML page and serves that copy to the next visitor instead of rebuilding it. Wonderful for speed. Awkward for a shop, for three reasons.
1. Prices and stock change
The plugin syncs as often as every five minutes. A page cached for 24 hours will show a price from 24 hours ago, and stock from 24 hours ago. Customers add out-of-stock items to a cart, or see a price they will not be charged.
2. Carts are personal
The cart is different for every visitor. A cached page with someone else’s cart in it is a disclosure problem, not just a display bug. The plugin is built to avoid this — the cart sidebar renders empty and its contents load separately — but the cart’s own responses must never be cached.
3. Full storefront mode sets a session cookie
In Full storefront mode, a PHP session starts on every request, which sets a PHPSESSID cookie.
Most caching plugins refuse to cache any response that sets a session cookie, so you can end up with a cache that never caches anything — a fast setup made slow by a misconfiguration.
What must never be cached
Exclude these from full-page caching, always:
| What | Why |
|---|---|
/wp-admin/admin-ajax.php |
Every cart operation goes through it |
| The Checkout page | Session-specific |
| Any thank-you or order-complete page | Carries the transaction ID |
| Pages using the live detail shortcodes | [dispense_product_cannabinoids], [dispense_product_terpenes], [dispense_product_effects], [dispense_product_terpenes_type], [dispense_product_cannabis_type] fetch from AIQ Ecommerce at render time |
Exclude these from object caching and cookie-ignoring rules:
| Cookie | Why |
|---|---|
PHPSESSID |
Identifies the visitor's cart session |
dispense_cart_id |
The cart reference |
dispense_venue_id |
The cart's venue |
Never strip or ignore those three. A cache or CDN that removes them empties every visitor’s cart.
What is safe to cache
| What | Why |
|---|---|
| The cart sidebar's markup | It renders identically for every visitor; the contents load by JavaScript afterwards |
| Category and brand archives | With a short expiry — see below |
| Product listings without live shortcodes | With a short expiry |
| CSS, JavaScript, images | Cache these hard |
| The all-offers page | With a short expiry |
Recommended settings for common caching plugins
Whichever you use, three things are constant: exclude admin-ajax.php, exclude checkout, and keep page cache lifetimes short on anything showing prices.
WP Rocket
Advanced Rules → Never Cache URL(s):
/dispense-checkout/
/checkout/
/(.*)/product/(.*)
(Drop the third line if your product pages do not use the live detail shortcodes.)
Advanced Rules → Never Cache Cookies:
PHPSESSID
dispense_cart_id
dispense_venue_id
Cache → Cache Lifespan: 1 hour on product pages, longer elsewhere.
File Optimization: be cautious. Delaying or deferring JavaScript can break the cart — the cart script must run for the sidebar to populate. If you delay JavaScript, exclude:
dispense-cart.js
dispense-product-filters.js
dispense-product-details.js
W3 Total Cache
Page Cache → Advanced → Never cache the following pages:
dispense-checkout
checkout
Page Cache → Advanced → Rejected cookies:
PHPSESSID
dispense_cart_id
dispense_venue_id
Minify: exclude the three AIQ Ecommerce scripts if you enable JavaScript minification or combining.
LiteSpeed Cache
Cache → Excludes → Do Not Cache URIs:
/dispense-checkout/
/checkout/
Cache → Excludes → Do Not Cache Cookies:
PHPSESSID
dispense_cart_id
dispense_venue_id
Cache → TTL → Public Cache TTL: 3600 (1 hour) rather than the default day.
Page Optimization → JS Settings: turn JS Defer off, or exclude the AIQ Ecommerce scripts.
WP Super Cache
Advanced → Rejected URL strings:
/dispense-checkout/
/checkout/
Advanced → Rejected Cookies:
PHPSESSID
dispense_cart_id
dispense_venue_id
Use Expert mode with care — mod_rewrite caching bypasses PHP entirely and will not honour session-based exclusions.
Cloudflare
Cloudflare sits in front of everything, so its rules matter most.
Page Rules / Cache Rules — bypass the cache for:
example.com/wp-admin/*
example.com/dispense-checkout*
example.com/checkout*
Caching → Configuration:
- Caching Level: Standard
- Browser Cache TTL: 4 hours or less on HTML
Rocket Loader: turn it off. It reorders JavaScript execution and reliably breaks the cart.
Automatic Platform Optimization (APO): if you use it, add the cart cookies to its bypass list.
Managed hosting caches
Kinsta, WP Engine, SiteGround, Cloudways and similar run their own server-level caches. They usually exclude admin-ajax.php and common checkout paths automatically, but they do not know about /dispense-checkout/. Ask support to add:
- Bypass cache for
/dispense-checkout/and any custom checkout URL - Bypass cache for requests carrying
dispense_cart_id
Keeping prices and stock accurate
Caching sits on top of syncing, and the two delays add up:
Price changes in AIQ Ecommerce
→ up to 30 minutes until the next sync (default interval)
→ up to your cache lifetime until visitors see it
With a 30-minute sync and a 24-hour cache, a customer can see a price a day out of date.
Setting the two together
| Store type | Sync interval | Page cache lifetime |
|---|---|---|
| Fast-moving stock, frequent price changes | 5–15 minutes | 15 minutes on product pages |
| Typical dispensary | 30 minutes | 1 hour |
| Slow-moving catalogue | Hourly | 4 hours |
| Display-only site | Twice daily | 12 hours |
Rule of thumb: the cache lifetime on any page showing a price should be no longer than the sync interval. Otherwise the cache is the bottleneck and shortening the sync interval achieves nothing.
Clearing the cache after a sync
Most caching plugins can be told to purge on demand. If yours exposes a hook or a WP-CLI command, purging product pages after a sync gives you the best of both — long cache lifetimes and fresh prices. Ask your developer; it is a few lines hooked to the sync’s completion.
Making stock visibly current
Even with good caching, a price on a cached page is a snapshot. Two ways to be honest about that:
- Show stock rather than implying it. Display
dispense_product_quantity, and mark low stock. - Rely on the cart. Prices and availability are re-checked by AIQ Ecommerce when an item is added, so a customer cannot actually buy at a stale price. The cached page can be behind; the transaction cannot.
Guidance for large catalogues
Above roughly 1,000 products, a few things start to matter.
The database
- Add object caching. Redis or Memcached, through a plugin like Redis Object Cache. This is the single biggest improvement for a large catalogue.
- Keep listing page sizes modest. 12–24 products. Products Per Page on the General tab controls archives.
- Prefer taxonomy filters to custom-field filters. Taxonomies are indexed; post meta is not, so a price-range facet is much heavier than a brand facet.
The sync itself
- Lengthen the interval. A full pass over 3,000 products every five minutes leaves your server permanently syncing. Check the Duration in the Sync Status panel and set the interval comfortably longer.
- Use a real cron. WP-Cron runs on page views, so a long sync can be triggered by an unlucky visitor and slow their page. Disable WP-Cron and use a server cron:
In wp-config.php:
define('DISABLE_WP_CRON', true);
Then a server cron every five minutes:
*/5 * * * * curl -s https://yoursite.com/wp-cron.php?doing_wp_cron > /dev/null
- Raise PHP limits.
max_execution_time300,memory_limit256M or more.
Images
Images are served from AIQ Ecommerce’s URLs rather than your media library, so they cost you no disk space and no sync time — but they are also outside your control:
- You cannot resize or convert them to WebP yourself.
- Set
widthandheighton your image elements so the browser reserves space, which keeps your layout stability score healthy. - Add
loading="lazy"to images below the fold.
Front end
- Keep loop templates lean. Every element multiplies by the number of products.
- Do not put the live detail shortcodes in a listing — they make an API call each, so twelve products means twelve calls.
- Use pagination rather than infinite scroll on large menus.
A pre-launch caching checklist
- [ ]
admin-ajax.phpis excluded from the page cache - [ ] The checkout page is excluded
- [ ]
PHPSESSID,dispense_cart_idanddispense_venue_idare in the “never cache” cookie list - [ ] Product pages using live shortcodes are excluded
- [ ] Page cache lifetime is no longer than the sync interval on price-bearing pages
- [ ] AIQ Ecommerce JavaScript is excluded from any delay/defer optimisation
- [ ] Cloudflare Rocket Loader is off
- [ ] The cart works in a private browsing window
- [ ] The cart survives navigating between pages
- [ ] Checkout loads and completes
- [ ] Prices on the front end match AIQ Ecommerce after a sync
Common problems
Prices are wrong on the site but right in the admin.
Caching. Clear the page cache and shorten the lifetime.
The cart empties when moving between pages.
The cache or CDN is stripping cookies. Add the three cart cookies to the never-cache list.
The cart works logged in but not logged out.
Logged-in users bypass most caches. The logged-out experience is the cached one — that is your bug.
My caching plugin says it is caching nothing.
The session cookie in Full storefront mode. Configure cookie handling as above, or consider Sync only mode.
Add to cart does nothing after enabling optimisation.
JavaScript delay, defer or combining has broken the cart script. Exclude dispense-cart.js.
The checkout page is blank behind Cloudflare.
Bypass the cache for the checkout URL, and turn Rocket Loader off.
The site is slow during syncs.
The sync is running on a visitor’s page load. Move to a real server cron and lengthen the interval.
Everything is fast but stock is always wrong.
Cache lifetime is longer than the sync interval. Bring it down.