Filter hook 'rest_send_nocache_headers'

in WP Core File wp-includes/rest-api/class-wp-rest-server.php at line 485

View Source

rest_send_nocache_headers

Filter Hook
Description
Filters whether to send no-cache headers on a REST API request.

Hook Information

File Location wp-includes/rest-api/class-wp-rest-server.php View on GitHub
Hook Type Filter
Line Number 485

Hook Parameters

Type Name Description
bool $rest_send_nocache_headers Whether to send no-cache headers.

Usage Examples

Basic Usage
<?php
// Hook into rest_send_nocache_headers
add_filter('rest_send_nocache_headers', 'my_custom_filter', 10, 1);

function my_custom_filter($rest_send_nocache_headers) {
    // Your custom filtering logic here
    return $rest_send_nocache_headers;
}

Source Code Context

wp-includes/rest-api/class-wp-rest-server.php:485 - How this hook is used in WordPress core
<?php
 480  		 * @since 4.4.0
 481  		 * @since 6.3.2 Moved the block to catch the filter added on rest_cookie_check_errors() from wp-includes/rest-api.php.
 482  		 *
 483  		 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
 484  		 */
 485  		$send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
 486  
 487  		/*
 488  		 * Send no-cache headers if $send_no_cache_headers is true,
 489  		 * OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code.
 490  		 */

PHP Documentation

<?php
/**
		 * Filters whether to send no-cache headers on a REST API request.
		 *
		 * @since 4.4.0
		 * @since 6.3.2 Moved the block to catch the filter added on rest_cookie_check_errors() from wp-includes/rest-api.php.
		 *
		 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/rest-api/class-wp-rest-server.php
Related Hooks

Related hooks will be displayed here in future updates.