Best settings for avoiding cached nonce issues
-
I recently came up against an issue where a nonce stored in a cached HTML page had expired and caused a 403 at admin-ajax.php.
I now realise that my pages (Disk: Enhanced) need to expire before any nonce does. However that leads me to what settings do I need to best handle this?
I think that setting the “Maximum lifetime of cache objects” under the Page cache settings needs to change, but that alone can’t be enough since the HTML pages will persist past this value until the garbage collection runs. Is that correct? So I’m thinking that the garbage collection interval needs to be adjusted too? I’m assuming the garbage collection removes expired files and doesn’t just delete _old.html files?
I also considered just excluding the pages that I know had nonces in the HTML (in this case a Gravity Form with Stripe payment) but looking at the HTML I see all pages on my sites have nonces for various things (Elementor outputs them). So realistically this issue could happen anywhere.
I’d really appreciate a hand identifying the values that need to change and what to.
What I have implemented now, knowing that a nonce can live between 12-24 hours is a expiry of 36,000 (10 hours) with garbage collection 3,600 (1 hour) with a real cron running every 15 minutes. Does that seem reasonable to mitigate the issue or should I be concerned with anything else?
- You must be logged in to reply to this topic.