Prevent W3 Total Cache from caching nonces

845 views Asked by At

My WordPress site has a custom implementation of forms that frequently use AJAX calls to communicate to external APIs. I have been using WordPress nonces for AJAX calls. Recently, I decided to setup W3 Total Cache for optimization purposes. Everything was smooth except for the fact that I believe W3 Total Cache is caching nonces as well. Therefore, they stay there past their default expiry time of 24 hours. As a result, whenever I access forms on the website, AJAX calls fail and I receive nonce verification failed error. The moment I clear the cache from W3TC, AJAX calls get back to normal.

Can anyone provide any help with this? I have tried setting cache expiry time less than 24 hours with the hope that cache would get cleared before the nonce expires but this didn't help either. I am using WordPress 5.4 on Windows/IIS server running PHP 7.4

1

There are 1 answers

0
Osama Ibrahim On

Never mind. I figured out that WP_CRON was disabled on my WordPress installation so the cache was getting cleared in the first place. Fixed it and now everything works fine.