gcapi_gppa_should_cache
Description
Filter whether to use cached GPPA endpoint responses.
Usage
Applied globally
add_filter( 'gcapi_gppa_should_cache', 'my_custom_function' );
Parameters
$should_cache
bool
Whether to use cached responses.
$cache_key
string
The cache key.
$endpoint_config
array
The GPPA endpoint configuration.
Examples
Disable caching during development
add_filter( ‘gcapi_gppa_should_cache’, function( $should_cache ) { return ! ( defined( ‘WP_DEBUG’ ) && WP_DEBUG ); });
Disable caching for admin users
add_filter( ‘gcapi_gppa_should_cache’, function( $should_cache ) { return ! current_user_can( ‘manage_options’ ); });
Conditional caching based on endpoint path
add_filter( ‘gcapi_gppa_should_cache’, function( $should_cache, $cache_key, $endpoint_config ) { // Don’t cache endpoints with ‘real-time’ in the path return ! str_contains( $endpoint_config[‘endpoint_path’] ?? ”, ‘real-time’ ); }, 10, 3 );
Since
1.0.0
Hook added.