header( 'Cache-Control', 'no-store, no-cache, must-revalidate, private' ); $response->header( 'Pragma', 'no-cache' ); return $response; } /** * Attach explicit-public caching headers to a `WP_REST_Response` that * IS meant to be edge-cached (e.g. static health/version endpoints, * discovery documents). Opposite of `apply_to_rest_response()`. * * @param \WP_REST_Response $response * @param int $max_age Seconds. Defaults to 1 hour. * @return \WP_REST_Response */ public static function apply_public_cache_to_rest_response( \WP_REST_Response $response, int $max_age = 3600 ): \WP_REST_Response { $response->header( 'Cache-Control', sprintf( 'public, max-age=%d', max( 0, $max_age ) ) ); return $response; } }