Page cache purging
A cached page is a copy of the page as it was when the cache built it. When a sale starts or ends, a cached page can keep showing the old prices or the old list of sale products until the cache is purged. Price Discounts purges the page cache for you at those moments.
Available since 0.4.0.
The option
Open Advanced at the bottom of the Discounts tab. Purge the page cache when a sale starts or ends, and when rules are saved is ticked by default.
Underneath, the tab names the page cache it found, for example “Page cache found: WP Rocket.”, and the last purge with its reason, for example “Last purge: 28 November 2026 00:00 (rule Black Friday jackets started).”
When it purges
| Moment | Reason shown |
|---|---|
| You save the Discounts tab | discount rules saved |
| A rule’s From time arrives | rule … started |
| A rule’s To time passes | rule … ended |
| Sale prices change at any other time, for example when a product joins a rule’s category, or when Super Speedy Ajax switches between TEST and LIVE | sale prices changed |
Purges at a From or To time apply to every rule that is switched on, display-only rules included. They run on WP-Cron, through WooCommerce’s scheduled actions, so on a quiet site they can run a little after the time you set.
Each purge clears the whole page cache, because a sale changes prices on the shop, category pages, product pages, search results and Sale pages at once.
Supported page caches
The add-on calls the page cache’s own purge function:
- WP Rocket
- LiteSpeed Cache
- W3 Total Cache
- WP Super Cache
- SG Optimizer
- Nginx Helper
- Cachify
If more than one is active, the first in this list is purged.
Any other cache
A cache it does not know, such as a CDN or your host’s server cache, can hook the ssappd_purge_page_cache action, which fires on every purge whether or not a supported cache plugin is found:
add_action( 'ssappd_purge_page_cache', function ( $why ) {
// Purge your CDN or host cache here. $why is the reason, e.g. "rule Black Friday jackets started".
my_host_purge_everything();
} );
The Developer Reference lists every hook.
Super Speedy Ajax’s Prices setting
Super Speedy Ajax has a Prices setting on its Main tab, and it changes what a cached page shows.
- In the cached page. A cached page keeps the price it was built with until the page cache is purged. Keep the purge option ticked. The Discounts tab shows a reminder under Advanced while this setting is in use.
- Fetched per visitor. A cached page fetches the current price on every page view, so prices are right without a purge, including when a scheduled rule starts or ends. It costs one extra request per page view, which discount rules do not need, because a rule gives every visitor the same price. The Discounts tab says so under Advanced while this setting is in use.
Either way, which products a page lists (a Sale page, a category page sorted by price) is part of the cached page, so the purge still matters. The basket and the checkout always show the current price.
If nothing else on your store prices by country, role or basket, set Prices to “In the cached page” and keep the purge option on. Pages then need no price request at all. “Do my prices differ between visitors?” on Super Speedy Ajax’s Main tab checks this for you.
Switching it off
Untick the option if you purge the cache yourself, or your cache expires pages within minutes. Purge the page cache by hand when you save rules and when a sale starts or ends.
Further reading
Written for Super Speedy Ajax – Price Discounts 0.4.3.
Comments