• Resolved aatospaja

    (@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 4 years, 5 months ago by aatospaja.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Anonymous User 16850768

    (@anonymized-16850768)

    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.

    Thread Starter aatospaja

    (@aatospaja)

    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?

    Anonymous User 16850768

    (@anonymized-16850768)

    You’re right, that does sound like that could occur. Can you please provide a detailed example of what’s occurring so I can see what other options are available (or what functionality needs to be added)? The AJAX call(s) and the error(s) returned would be helpful.

    Anonymous User 16850768

    (@anonymized-16850768)

    Since version 1.5.0 Ajax requests now bypass the cache.

    Thread Starter aatospaja

    (@aatospaja)

    First of all sorry for not getting back to you before. I must have missed your reply altogether.

    But anyways, great news on 1.5.0! Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘nonces and cache expiry’ is closed to new replies.