Support » Plugin: Cache Enabler - WordPress Cache » nonces and cache expiry

  • Resolved aatospaja


    How does cache expiry work? I’m trying to find a setting that would work in sync with wordpress nonces. WordPress nonces work like this by default:

    “WordPress uses a system with two ticks (half of the lifetime) and validates nonces from the current tick and the last tick. In default settings (24h lifetime) this means that the time information in the nonce is related to how many 12h periods of time have passed since Unix epoch. This means that a nonce made between midday and midnight will have a lifetime until midday the next day. The actual lifetime is thus variable between 12 and 24 hours. The example above will give you nonces that are valid for 2-4 hours.”

    How could I get this cache plugin to work properly? I keep having issues with my wp nonce depending ajax calls with cached pages where the nonce is already expired but the cached page is still trying to use it and therefore the process results in error.

    I’ve tried to have the cache expiry set to 12 hours but that doesn’t seem to work.

    • This topic was modified 1 month, 1 week ago by aatospaja.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Corey


    The Cache Expiry setting defines how long the cached pages are kept before being cleared and need to be generated again.

    The issue that you’re currently experiencing can be fixed by setting the Cache Expire setting to less than the value of the WordPress nonce that is causing this issue. For example, if the nonce is valid for 12-24 hours you would want your cached pages to expire after 11 hours.

    But isn’t that logic a bit flawed? Say, WP creates nonces at 12 and 24. Cache is set to expire in 11 hours. What if the cache ia cleared either manually or by publishing a post at 20. Nonces are created at 24 but cache isn’t expiring yet but at 4am. So the cached nonces aren’t valid for 4 hours.

    Is this right?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.