• Resolved mpicard

    (@mpicard)


    Hi there,

    First thank you so much for this great plugin !

    I’ve been trying to use the wp_rest_cache/skip_nonce_caching filter to allow caching when x-wp-nonce request header is set on one of my custom endpoint.

    But it seems this filter is never triggered, I tried from my theme or from a plugin, and even through the init hook like so :

    
    add_action( 'init', fn() => add_filter( 'wp_rest_cache/skip_nonce_caching', false ), 1 );
    

    It’s seems it’s always too late to be triggered. Am I doing something wrong ? (Note that I tested without the request header and the cache response is served)

    thanks for your help

    Michael

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @mpicard

    Thank you for using our plugin!

    Yes, the way you are using it, you are indeed always too late for it to be triggered. The reason for this has to do with the way we hook into WordPress to see if we need to serve a cache record. We install a must-use plugin which is loaded before the normal plugins and theme(s) are loaded, if we have a cache record for the current request we return it and no other code is executed.
    Now if that is the case, how can you use the wp_rest_cache/skip_nonce_caching filter? You have to create your own must-use plugin and make sure it is loaded before our must-use plugin is loaded (i.e. give it a name that is alphabetically before wp-rest-cache). In your own must-use plugin you can use the filter.

    Thread Starter mpicard

    (@mpicard)

    Hello @rockfire ,

    Makes sense, thank you for the detailed reply. I’ll do that then.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘skip_nonce_caching filter’ is closed to new replies.