You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: RPC and database calls break on pages cached longer than ~24 hours #176
Blockstudio injects its client credentials into the page HTML. Those credentials expire, so a page served from a cache for longer than that starts failing on RPC/database calls. The fix should fetch a fresh token when the page loads, the way islands already avoid embedding an expiring credential in cached HTML.
Current behavior / evidence
Rpc::get_client_script() injects a <script id="blockstudio-fn"> into </head> (via the blockstudio/buffer/output filter) containing both wp_create_nonce('wp_rest') and Csrf::generate() as X-WP-Nonce / X-BS-Token.
Database::get_client_script() does the same for bs.db(), so this is not RPC-only.
Csrf::generate() is wp_hash( wp_nonce_tick() . '|blockstudio_csrf' ), and Csrf::verify() accepts only the current and previous tick. WordPress nonce ticks rotate every 12 hours, so a token baked into cached HTML is valid for 12–24 hours depending on where in the tick it was generated — not a guaranteed day.
The WP REST nonce has the same ~24-hour ceiling.
Reproduction
Put a page with a public RPC function (or a db.php schema) behind a page cache with a TTL over 24 hours, or serve a stale cached copy.
Load the cached page after the token has aged out.
Call the public function. It fails with a CSRF error (blockstudio_fn_csrf, and the database equivalent), even though nothing about the site changed.
Functions set to 'open' are unaffected, since they skip the token check.
Expected behavior
A cached page should keep working. Either:
bs.fn() / bs.db() fetch a fresh token from a small, uncached, same-origin endpoint on page load (and/or retry once with a fresh token after a 403), or
public calls follow the island pattern and validate the request server-side without relying on a credential embedded in cached HTML.
Any fresh-token endpoint must itself be excluded from page caching, as the island fragment endpoint is.
Note on scope
Blockstudio's own static prerender docs say nonce-bearing pages are not prerendered, so this bites mainly external / long-TTL page caches. That's still the common case for anyone with a page cache, which is why this is filed as a bug rather than a docs note.
Fixed and released in Blockstudio 7.7.8. RPC, database calls, and realtime polling now obtain fresh visitor credentials lazily outside cached HTML and retry once when those credentials expire, without weakening permission checks. Regression coverage includes cached clients, expired nonce/CSRF recovery, authenticated requests, and rejected cross-origin requests.
Please purge existing full-page/CDN caches after upgrading so previously cached pages load the updated client.
Activity
Fix cached API credentials and add signed page context and extension …
dnnsjsk commentedon Oct 24, 2026
Fixed and released in Blockstudio 7.7.8. RPC, database calls, and realtime polling now obtain fresh visitor credentials lazily outside cached HTML and retry once when those credentials expire, without weakening permission checks. Regression coverage includes cached clients, expired nonce/CSRF recovery, authenticated requests, and rejected cross-origin requests.
Please purge existing full-page/CDN caches after upgrading so previously cached pages load the updated client.