<?php defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); add_filter( 'rocket_cache_reject_uri', '__rocket_exclude_wp_rest_api' ); function __rocket_exclude_wp_rest_api( $uri ) { /** * By default, don't cache the WP REST API. * * @since 2.5.12 * * @param bool false will force to cache the WP REST API */ $rocket_cache_reject_wp_rest_api = apply_filters( 'rocket_cache_reject_wp_rest_api', true ); // Exclude WP REST API if( function_exists( 'json_get_url_prefix' ) && $rocket_cache_reject_wp_rest_api ) { $uri[] = '/' . json_get_url_prefix() . '/(.*)'; } if ( class_exists( 'WP_REST_Controller' ) && $rocket_cache_reject_wp_rest_api ) { $uri[] = '/wp-json/(.*)'; } return $uri; }