rest_send_nocache_headers

Send nocache headers on authenticated requests.

Description

apply_filters( 'rest_send_nocache_headers', (bool) $is_user_logged_in ); 

Parameters (1)

0. $is_user_logged_in (bool) => is_user_logged_in()
Whether to send no-cache headers.

Usage

To run the hook, copy the example below.
  1. $is_user_logged_in = apply_filters( 'rest_send_nocache_headers', $is_user_logged_in ); 
  2.  
  3. if ( !empty( $is_user_logged_in ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_send_nocache_headers callback 
  2. function filter_rest_send_nocache_headers( $is_user_logged_in ) { 
  3. // make filter magic happen here... 
  4. return $is_user_logged_in
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_send_nocache_headers', 'filter_rest_send_nocache_headers', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_send_nocache_headers', 'filter_rest_send_nocache_headers', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/rest-api/class-wp-rest-server.php  
  1. $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );