The wordpress_no_cache Staff Marker
The Cache Upgrader Kit for WooCommerce gives every administrator and shop manager a cookie called wordpress_no_cache when they log in. It tells the page cache to build that person a fresh page instead of handing them the shared cached copy. This guide explains why the kit needs it, which caches are known to honour it, and how to check yours.
Why the kit sets it
Most page caches decide who gets a cached page by looking at cookie names. A browser carrying the WordPress login cookie, wordpress_logged_in_ā¦, is treated as logged in, and the cache steps aside. That is why logged-in customers normally get slow, uncached pages.
To let logged-in customers share the cached page, the kit renames that login cookie. WordPress still knows exactly who the customer is, but the cache does not see a login cookie, so it serves them the same cached page as a guest. Their own details, such as their basket and account menu, are filled in afterwards by Super Speedy Ajax.
The rename applies to everyone who logs in, including the people who run the store. Staff need fresh pages: they edit products and check changes, and they expect to see the admin bar and edit links. So for anyone who can edit content or manage the shop, the kit adds the wordpress_no_cache cookie as well. It is a cookie name many page caches bypass on, so those caches keep staff on fresh pages without any extra configuration.
Who gets it
The cookie is set at login for any user with at least one of these WordPress capabilities:
| Capability | Usually held by |
|---|---|
edit_posts | Administrators, editors, authors and contributors |
manage_woocommerce | Administrators and shop managers |
manage_options | Administrators |
Customers and subscribers do not get it, which is what lets them share the cached page.
The timing matters. Once the login cookie is renamed, a staff member’s front-end requests can be answered straight from the cache, and a cached answer never reaches WordPress. Setting the marker during login means the first page they open after logging in is a fresh one.
The kit also keeps the marker in step on later visits: it adds it for a staff member whose session started without it, and removes it from a browser where a customer has logged in after a staff member. Logging out removes it too.
The marker is not a security boundary, and it does not need to be one. Anyone can add the cookie to their own browser, and all it does is make the cache build them a fresh page: much as a random query string on the URL does. It never gives anybody access to anything.
Caches known to honour it
These are the caches where we have tested that a request carrying wordpress_no_cache gets a freshly built page:
| Page cache | Honours the marker | Status header to look for |
|---|---|---|
| GridPane (nginx FastCGI cache) | Yes, by default. Tested on our own demo store | x-grid-cache |
| RunCloud Hub (nginx cache) | Yes, by default | x-runcloud-cache |
| xSpeed (xCloud) | With the library recipe xspeed-staff-marker, in Cache Upgrader 1.7.19 and later | x-xspeed-cache |
xSpeed’s server rules and its advanced-cache.php drop-in step aside for the marker, but its PHP serve path does not, so without the recipe a marker request still gets the stored page. Your AI agent can switch the recipe on for a store that runs xSpeed.
Other caches may honour the marker as well. The list above is only the ones we have proved. Some page-cache plugins do not check it by default: WP-Optimize 4.6.1, for example, only checks the standard WordPress cookie names plus whatever you add to its cookie exceptions.
Check your own cache
You need two requests to the same page, one without the cookie and one with it. Run each a couple of times so the page is in the cache first:
curl -s -o /dev/null -D - https://your-store.example/shop/ | grep -i cache
curl -s -o /dev/null -D - -b 'wordpress_no_cache=1' https://your-store.example/shop/ | grep -i cache
On our demo store, which runs GridPane, the first request answers x-grid-cache: HIT and the second answers x-grid-cache: BYPASS. That is the result you want: cached for a guest, fresh when the marker is present.
Your header name depends on your cache. Look for one of x-grid-cache, x-runcloud-cache, x-xspeed-cache, x-cache, x-cache-status, x-litespeed-cache or cf-cache-status. If the marker request still says HIT, the cache is ignoring the marker. If neither request carries a cache header at all, ask your host which header their cache sends.
Testing only once. The first request to a page is often a MISS simply because nothing was in the cache yet, which looks the same as a bypass. Send the guest request until it says HIT, then send the marker request.
The kit’s own safety checks run this test for you, as part of the safety loop described in How the Kit Works, so your agent reports a cache that ignores the marker before you go live.
What happens if a cache ignores it
Staff are served the shared guest page from the cache: the same page every guest sees, with no admin bar and no edit links, and without a recent edit until the cache is cleared. They do not see any other visitor’s data, because the shared page has nothing personal in it. That is the point of the kit.
Anything WordPress builds itself is unaffected. wp-admin, the basket, checkout and My Account are not served from the shared cache, so staff can still work normally. The only thing that goes wrong is that the shop front looks like a guest’s view to them.
The fix depends on the cache. For xSpeed it is the library recipe above. For another cache, add wordpress_no_cache to its list of cookies that bypass the cache, or ask your AI agent to find out how that cache can be told to step aside for it.
For developers
The capabilities that earn the marker go through the ssap_no_cache_caps filter. Any one capability in the list is enough:
add_filter('ssap_no_cache_caps', function ($caps) {
$caps[] = 'edit_shop_orders';
return $caps;
});
The cookie is set with the site’s cookie path and domain, HttpOnly, and Secure on HTTPS sites, with value 1.
Further reading
Written for Cache Upgrader for WooCommerce 1.7.20.
Comments