comet-cache icon indicating copy to clipboard operation
comet-cache copied to clipboard

Feature Request: Extend Caching of Nonces for Logged-In Users where nonce_life filter used

Open KTS915 opened this issue 7 years ago • 1 comments

I understand that Comet Cache sensibly limits the lifetime of a cache that includes a nonce for the following reason (explained in #793):

Ensure the cache file that contains a Nonce value does not stay around for longer than the minimum lifetime of a WordPress Nonce, which is 12 hours. If it stays around for longer than 12 hours, then the user who loads the cache file will find themselves clicking buttons and submitting forms that result in an error due to the expired Nonce value.

I have recently come across a plugin called Nonce Extender. A quick look in its code showed me that it uses a WP filter called nonce_life that I had not heard of before, but which allows a user to extend the life of a nonce.

So I am wondering whether it would be possible for Comet Cache to detect whether such a filter has been used on a site, and then to adjust the lifetime of the cache to reflect the adjusted lifetime of the nonce. (Just to be clear, I am suggesting this only for nonces of logged-in users.)

KTS915 avatar Apr 13 '17 13:04 KTS915

Here's the relevant nonce_life line in WordPress: https://github.com/WordPress/WordPress/blob/4.7.3/wp-includes/pluggable.php#L1822

The only problem I see with dynamically adjusting the cache expiration time is that would mean adjusting the cache expiration time for all of the cache (including anonymous visitors). It's currently not possible to dynamically specify a cache expiration time (although we do have a related GitHub issue open here: https://github.com/websharks/comet-cache/issues/170).

@jaswrks Any thoughts on this feature request?

raamdev avatar Apr 13 '17 21:04 raamdev