\MatthiasWeb\UtilsServiceNoStore

Add `no-store` cache control directive to WP REST API requests.

Summary

Methods
Properties
Constants
rest_send_nocache_headers()
rest_post_dispatch()
getNamespace()
hook()
instance()
No public properties found
CACHE_CONTROL_HEADER
CACHE_CONTROL_VALUE_NO_STORE
No protected methods found
No protected properties found
N/A
__construct()
$namespace
N/A

Constants

CACHE_CONTROL_HEADER

CACHE_CONTROL_HEADER ='Cache-Control'

CACHE_CONTROL_VALUE_NO_STORE

CACHE_CONTROL_VALUE_NO_STORE ='no-cache, no-store, must-revalidate, max-age=0'

Add `no-store` to default content type.

Properties

$namespace

$namespace :

Type

Methods

rest_send_nocache_headers()

rest_send_nocache_headers(boolean  $rest_send_nocache_headers)

Check if a given REST API should send the nocache headers in general and add a filter to modify the header.

Parameters

boolean $rest_send_nocache_headers

Whether to send no-cache headers.

rest_post_dispatch()

rest_post_dispatch(\WP_HTTP_Response  $result,\WP_REST_Server  $server,\WP_REST_Request  $request)

Add `no-store` to nocache headers, but only once and only if not already modified through endpoint.

Parameters

\WP_HTTP_Response $result

Result to send to the client. Usually a WP_REST_Response.

\WP_REST_Server $server

Server instance.

\WP_REST_Request $request

Request used to generate the response.

getNamespace()

getNamespace()

Get namespace.

hook()

hook(string  $namespace)

Create and hook a `no-store` service for a given namespace starting with.

Parameters

string $namespace

Must start with a leading slash!

instance()

instance(string  $namespace): \MatthiasWeb\Utils\ServiceNoStore

Get a new instance of ServiceNoStore.

Parameters

string $namespace

Must start with a leading slash!

Returns

\MatthiasWeb\Utils\ServiceNoStore

__construct()

__construct(string  $namespace)

C'tor.

Parameters

string $namespace