Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Cached form nonce expired: why your form rejects submissions

OPS-110High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A nonce (number used once) is a hidden value in a form. The server created it for a visitor and a time window, and checks it on submit. This blocks forged requests, known as CSRF. Some platforms call it a CSRF token or form token.

Page caching saves one copy of the HTML and shows it to everyone. The copy contains the nonce from the moment it was saved. Once the nonce expires (WordPress nonces last up to 24 hours by default, in two 12-hour halves), every visitor who loads the cached copy submits a dead token. The server answers with an error such as 'Security check failed', 'Link expired' or a 403.

How a cached nonce kills a lead
  1. Page cachedCache saves HTML with nonce A
  2. Nonce expiresServer no longer accepts nonce A
  3. Visitor submitsOld nonce sent with the form
  4. Form rejectedError or silent failure
  5. Lead and trackingNo email, CRM entry or conversion tag

The page looks fine. The failure only appears on submit.

Why it costs you leads or sales

The visitor filled in the form and clicked send, so they were ready to buy or enquire. A rejection at that point loses them. Many will not retry, and some never see a clear error. You also lose the conversion event, so ad platforms see fewer results and optimise on bad data.

It tends to get worse over time. Right after the cache is purged, forms work. As the cached copy ages past the nonce lifetime, more submissions fail. The problem comes and goes, which makes it easy to miss.

Share of submissions accepted as the cached page agesExample numbers
Share of submissions accepted as the cached page ages (example)Just after purge: 100 %; 12 hours: 90 %; 24 hours: 40 %; 36 hours: 5 %0387710090405Just after purge12 hours24 hours36 hours%

Example: illustrative numbers showing acceptance falling once the cached nonce passes its lifetime.

How to check if your site has it

Check for a cached nonce
  1. Open the form page in a private window

    Use a logged-out session, because many caches skip logged-in users.

  2. View the page source

    Search for 'nonce', '_wpnonce', 'csrf' or 'token' in a hidden input. Note the value.

  3. Compare from another browser or device

    If the same value appears for different visitors, the page is cached with that token.

  4. Check response headers

    In browser dev tools, Network tab, look for cf-cache-status: HIT, x-cache: HIT, x-litespeed-cache: hit or age greater than 0 on the page request.

  5. Submit the form after the page has been cached for a day

    If it fails with a security or expired message while a freshly purged page works, the nonce is the cause.

How to fix it

There are two safe approaches. Either stop the form page being cached, or keep the cache and fetch a fresh nonce with JavaScript after load. The first is simpler. Pick the steps for your platform.

Fix by platform
  1. Exclude the form page from page cache

    In your cache plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache) add the page URL to the 'never cache' or 'exclude URLs' list.

  2. Shorten the cache lifetime if you must cache

    Set cache lifespan below 12 hours so the nonce is still valid. WP Rocket: Cache > Cache Lifespan.

  3. Check your form plugin settings

    Some plugins (Gravity Forms, WPForms, Contact Form 7) offer options to load the nonce or token dynamically. Update the plugin and read its caching notes.

  4. Purge all caches

    Clear plugin, server and CDN caches so the old copy is gone.

Exclude the form from your CDN too

A plugin exclusion is not enough if your CDN caches HTML. In Cloudflare, create a Cache Rule (Caching > Cache Rules) that matches your form page path and sets the action to Bypass cache. Other CDNs have an equivalent path-based bypass rule.

Cloudflare Cache Rule exampletext
If: URI Path equals /contact/
Then: Cache eligibility = Bypass cache
Apache: stop caching a form pagehtaccess
<If "%{REQUEST_URI} == '/contact/'">
  Header set Cache-Control "no-store, private"
</If>

How to confirm it's fixed

Confirmation checklist
  • Purge plugin, server and CDN caches.
  • Reload the form page logged out and check the response header shows no cache HIT (or BYPASS).
  • Compare the hidden nonce value across two browsers: it should differ or load by script.
  • Submit a test lead and confirm it reaches your inbox and CRM.
  • Check the conversion tag fires on the thank-you step.
  • Repeat the test the next day to be sure it still works after the old nonce would have expired.
Form page before and after

Cached form page

  • Everyone gets the same saved nonce
  • Works after purge, fails later
  • Visitors see 'security check failed'
  • Leads and conversions silently lost

Form page bypasses cache

  • Each visit gets a valid token
  • Submissions accepted at any hour
  • Leads reach inbox and CRM
  • Conversion tags fire normally

How to prevent it happening again

Prevention habits
  • Keep a list of every page with a form and make sure each is excluded from caching.
  • Recheck exclusions after changing cache plugin, theme, host or CDN.
  • Add new landing pages to the exclusion list at launch.
  • Test submissions logged out, not as admin.
  • Test again a day after any cache setting change, because the failure appears only after the nonce ages.

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor loads your form page as a normal visitor would, fills in the form and submits it on a schedule. When the cached nonce has expired, the submit fails, and the check flags it as 'Submit fails'.

A failure is re-checked from a second region before one alert goes out, by email, Slack, Teams, WhatsApp, webhook or PagerDuty. The alert includes a screenshot and a likely cause. Because the check repeats, it can catch the on-and-off pattern as caches age. Test traffic is marked with utm_source=funnelguard, fg_test=1, an fg_test cookie and its own user agent. The Free plan covers 1 site with 2 journeys and daily checks, no card needed.

How a scheduled check catches it
  1. Example: 09:00

    Cache purged after a deploy. Form works.

  2. Example: next day 10:00

    Cached nonce has expired. Real visitors start to fail.

  3. Example: next day 10:15

    Scheduled check submits the form and it fails.

  4. Example: next day 10:20

    Second region confirms, one alert is sent with a screenshot.

Submit hits an expired token

The visitor sends the form and the server rejects the old nonce.

Questions people ask

Why does my form say 'security check failed' or 'link expired'?

The form contains a security token (nonce) that has expired or does not match. This often happens when a cache or CDN serves a saved copy of the page with an old token. Exclude the form page from caching and test again.

What is a nonce in a web form?

A nonce is a one-time or short-lived value that the server puts in a form and checks on submit. It proves the request came from your own page and stops forged submissions. If the value is old or missing, the server rejects the form.

Why does my form work after clearing the cache but fail later?

Right after a purge the page is rebuilt with a fresh nonce. The cache then keeps that copy, and once the nonce expires, submissions fail. Excluding the page from caching removes this pattern.

How do I stop WordPress caching a contact form page?

Add the page URL to the exclude or never-cache list in your cache plugin, then purge all caches. If you use a CDN such as Cloudflare, add a Bypass cache rule for the same path too.

Does Cloudflare cache pages with forms?

By default Cloudflare caches static files, not HTML. If you use a rule or plugin that caches everything, or full-page caching, form pages can be stored too. Add a Cache Rule with Bypass cache for the form path.

Can I fix an expired nonce by making it last longer?

It is not a good fix. A longer lifetime weakens the protection and the cached copy still expires eventually. Bypass caching for the form page or load a fresh token after the page loads.

How can I tell if a cached nonce is rejecting my leads?

Test the form logged out, a day after the last cache purge. If it fails then but works right after a purge, the nonce is likely the cause. A scheduled test submission, such as FunnelGuard runs, can catch this automatically.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: Submit fails.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.