I created the nonce when I localize a script file:

wp_localize_script('cad-search', 'cad_ajax', 
    array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
         'nonce'=> wp_create_nonce('cad_nonce'))


But when the nonce is evaluated in the function called through AJAX the values are not the same:

if ( !wp_verify_nonce( $_POST['nonce'], 'cad_nonce')) {
    exit('Missing nonce! Please refresh the page.');

This code works in Firefox but not in Chrome.

  • Does Chrome cache the page?
    – kero
    Feb 18, 2020 at 18:34
  • That could be a possibility since it is only happening on the front end. If so, what can be done about it? Caching would make nonces impossible to use.
    – AlanP
    Feb 18, 2020 at 18:57

1 Answer 1


Turning off a cache plugin, Fast Cache in this case, and adding 'define('WP_CACHE', false);' to the wp-config.php file seems to have resolved this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.