Contact Form Not Working on a Cached Page? Read This

Your contact form worked fine when you tested it. Then a visitor tells you it just spins, or shows an error, or says something vague about the page being invalid. You try it yourself, logged in as admin, and it works. So what’s going on?
Very often the answer is your page cache. Someone on the Contact Form 7 support forum asked it in the plainest possible way a few days ago, in a thread titled “Contact Forms on cached Pages”: “Could caching this page cause any issue? Should i exclude it from the cache”. WPForms users hit a cousin of the same thing, with the message “Attempt to submit corrupted post data”, and there are enough threads with that exact title that the forum slug has reached -11.
Short answer: yes, caching can break a form, but you usually don’t need to give up caching to fix it. Here’s why it happens, how to check your own site, and what the fixes are.
What a nonce is, in plain words
A nonce is a short security code WordPress prints into a page. When the form is sent, the code comes back with it, and WordPress checks it. If it matches and isn’t too old, the request goes through. It’s a cheap way for WordPress to say “this submit came from a page I actually served, recently”.
The “not too old” part is the trouble. According to the WordPress developer docs, a nonce has a lifetime of one day by default, but because of how WordPress splits that day into two halves (“ticks”), the real lifetime is anywhere between 12 and 24 hours. A nonce made in the afternoon might stop working by midday tomorrow.
For logged-out visitors, WordPress makes the same nonce for everyone during that window. That’s why caching a page with a form in it works at all. It’s also why it breaks later.
Why a cached page carries an old nonce
A page cache saves the finished HTML of a page and hands that copy to every logged-out visitor, so WordPress doesn’t have to build it again. Great for speed. But the saved copy includes whatever nonce was in the page when it was cached.
So if the cached copy of your contact page is, say, 20 hours old, the nonce inside it may already be dead. The visitor fills in the form, hits send, and WordPress refuses the code. Depending on the form plugin, that shows up as an error message, a spinner that never stops, or a form that quietly does nothing.
And you never see it, because logged-in users usually skip the cache entirely. You get a fresh page every time. Your visitors don’t.
A tab left open overnight does the same thing, cache or no cache. The page is just old.
One caveat on the WPForms error
To be fair to WPForms: their own doc on “corrupted post data” says the error usually appears when a captcha script (hCaptcha or reCAPTCHA) doesn’t load properly, and it points at caching and optimisation plugins that minify or delay JavaScript. That’s a related problem but not quite the nonce one. If you see that error, check whether the captcha widget actually shows on the page before blaming nonce age.
What cache plugins do about it
The careful ones set their default cache lifespan below the nonce lifetime. WP Rocket’s cache lifespan doc says the default is 10 hours and that “the default value is chosen to avoid any issues with WordPress nonces on your pages.” Their separate nonce article says to keep it under 12 hours, with 10 as a starting point, and that you may have to go down to 8 or less.
Two catches. First, if you’ve raised the lifespan to a few days to squeeze out more speed, you’ve walked right into the problem. Second, WP Rocket notes the lifespan setting doesn’t work on hosts where its own caching is turned off (they name WP Engine, Kinsta and WordPress.com). There the host’s cache is in charge, and you’d need to ask your host how long it keeps pages.
How to test your own site
The slow, honest test
- Make sure the contact page is in the cache (visit it once logged out).
- The next day, open it in a private window, so you’re a logged-out visitor.
- Fill the form in and send it. Then check the message actually arrived, not just that a success message showed.
If your cache lifespan is short enough, the cached copy will have been rebuilt and the test passes. If it’s longer than about 12 hours, this is where you’ll catch the failure.
The quick test on staging
Waiting a day is annoying. On a staging site (not your live site), you can shrink the nonce lifetime to two minutes with one line in a small plugin or your theme’s functions.php:
add_filter( 'nonce_life', fn() => 120 );
Then load the form page as a logged-out visitor (or save a copy of the cached HTML), wait three minutes, and submit. With a 120-second life, the nonce is surely dead by then, so you’re seeing exactly what a visitor sees on a stale cached page. Remove the line when you’re done.
If the form fails, you know the cause. If it works, your form plugin either doesn’t rely on a nonce for logged-out visitors or deals with an expired one somehow.
The usual fixes
1. Exclude the form page from the cache
Most cache plugins let you list URLs that never get cached. Add your contact page and the nonce is always fresh. This is the most reliable fix and the one forum replies suggest most.
The cost: that page is now built from scratch on every visit, so it’s slower and puts more load on the server. For one contact page, that’s usually fine. If you have forms in the footer or sidebar of every page, excluding them all means you’ve basically turned caching off, which is not fine.
2. Shorten the cache lifespan
Keep the lifespan under the 12-hour worst case. 10 hours is WP Rocket’s default for this reason. Shorter is safer but means more rebuilds. This fixes the cached-page case. It doesn’t fix the tab-left-open-overnight case, because that page is old no matter what your cache does.
3. Don’t lengthen the nonce life to match the cache
You’ll see people suggest raising nonce_life to a week so it outlasts the cache. It works, technically, but it makes every nonce on your site valid for longer, including ones that protect admin actions. We wouldn’t.
4. Use a form plugin that refreshes its token
Some form plugins fetch a fresh token with a small request when the page loads, or retry when the server says the token has expired. Then the cached HTML doesn’t matter much.
While you’re in there, also look at spam checks that use time. A “too fast” check (rejecting a form filled in within a couple of seconds) can misfire on a cached page if the timestamp was baked into the HTML. We cover how those checks work in our guide to stopping form spam.
And whatever fix you pick, make sure you’d actually notice if submissions stopped. A form that fails silently can go weeks before someone mentions it. Here’s how to tell if a form email failed.
How Trinity Forms handles a cached page
Full disclosure: Trinity Forms is ours. It’s a free download from our site, and it needs PHP 8.2 or newer. Everything below is in the free version.
- When the page loads, its script fetches a fresh signed time token for each form. That’s what the “too fast” spam check uses, so a visitor on a cached page doesn’t look like a bot.
- If WordPress refuses the page’s nonce as expired, the script fetches a new one and sends the form again on its own. The visitor sees nothing.
- If that also fails, it tells the visitor the page is out of date and keeps their answers in the form, so they don’t have to type it all again.
- Saving a published form empties the page cache of common cache plugins, so visitors see your change instead of the old version.
- Every entry is stored in WordPress, so a submission isn’t lost if the notification email goes missing.
What we tested, on 12 Nov 2026 with Trinity Forms Free 2.28.0: on a test site with the nonce life shortened to 120 seconds, we saved a copy of a contact page, waited until its nonce had expired and its page token was more than 5 minutes old, then filled it in as a logged-out visitor. It sent, “Thank you!” showed, and the entry was stored.
What we didn’t test: a visitor with JavaScript turned off. The refresh and retry happen in the script, so don’t assume they apply there.
If you want to try it, download Trinity Forms free and run the staging test above against it. For the rest of the contact page (what to ask, where to put the form), see our contact page checklist.
Frequently asked questions
Should I exclude my contact page from the cache?
Only if your form fails on a stale cached copy. Test first: open the page logged out the next day, or shorten the nonce life on staging and submit after a few minutes. If it fails, excluding the page is the most reliable fix. If it works, keep it cached.
How long does a WordPress nonce last?
One day by default, but the real lifetime is between 12 and 24 hours because WordPress splits the day into two halves. Plan for the 12-hour worst case when you set a cache lifespan.
Why does my form work when I test it but not for visitors?
You’re probably logged in, and most page caches skip logged-in users, so you always get a fresh page with a valid nonce. Visitors get the cached copy, which may carry an expired one. Test in a private window to see what they see.