Download the PHP package dwnload/wp-rest-api-object-cache without Composer
On this page you can find all versions of the php package dwnload/wp-rest-api-object-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dwnload/wp-rest-api-object-cache
More information about dwnload/wp-rest-api-object-cache
Files in dwnload/wp-rest-api-object-cache
Package wp-rest-api-object-cache
Short Description Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.
License MIT
Informations about the package wp-rest-api-object-cache
WordPress REST API Object Cache
Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.
Package Installation (via Composer)
To install this package, edit your composer.json
file:
Now run:
$ composer install dwnload/wp-rest-api-object-cache
- Actions
- How to use actions
- Filters
- How to use filters
Actions
Action | Argument(s) |
---|---|
Dwnload\WpRestApi\RestApi\RestDispatch::ACTION_CACHE_SKIPPED | mixed $result WP_REST_Server $server WP_REST_Request $request |
Dwnload\WpRestApi\WpAdmin\Admin::ACTION_REQUEST_FLUSH_CACHE | string $message string $type WP_User $user |
How to use actions
Filters
Filter | Argument(s) |
---|---|
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_CACHE_HEADERS | array $headers string $request_uri WP_REST_Server $server WP_REST_Request $request WP_REST_Response $response ( rest_pre_dispatch only) |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_CACHE_SKIP | boolean $skip ( default: WP_DEBUG ) string $request_uri WP_REST_Server $server WP_REST_Request $request |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_API_KEY | string $request_uri WP_REST_Server $server WP_REST_Request $request |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_API_GROUP | string $cache_group |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_CACHE_EXPIRE | int $expires |
Dwnload\WpRestApi\WpAdmin\Admin::FILTER_CACHE_UPDATE_OPTIONS | array $options |
Dwnload\WpRestApi\WpAdmin\Admin::FILTER_CACHE_OPTIONS | array $options |
Dwnload\WpRestApi\WpAdmin\Admin::FILTER_SHOW_ADMIN | boolean $show |
Dwnload\WpRestApi\WpAdmin\Admin::FILTER_SHOW_ADMIN_MENU | boolean $show |
Dwnload\WpRestApi\WpAdmin\Admin::FILTER_SHOW_ADMIN_BAR_MENU | boolean $show |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_ALLOWED_CACHE_STATUS | array $status HTTP Header statuses (defaults to array( 200 ) |
Dwnload\WpRestApi\RestApi\RestDispatch::FILTER_CACHE_VALIDATE_AUTH | boolean $authenticated WP_REST_Request $request |
How to use filters
Sending headers.
Changing the cache expire time.
Validating user auth when ?context=edit
Skipping cache
Deleting cache
Soft delete:
Append RestDispatch::QUERY_CACHE_DELETE
to your query param: add_query_arg( [ RestDispatch::QUERY_CACHE_DELETE, '1' ], '<url>' )
.
soft delete will delete the cache after the current request completes (on WordPress shutdown).
Hard delete: Append RestDispatch::QUERY_CACHE_DELETE
&& RestDispatch::QUERY_CACHE_FORCE_DELETE
to your query param:
add_query_arg( [ RestDispatch::QUERY_CACHE_DELETE, '1', RestDispatch::QUERY_CACHE_FORCE_DELETE, '1' ], '<url>' )
.
hard delete will delete the cache before the request, forcing it to repopulate.
empty ALL cache on post-save this is not ideal
You can use the WordPress filter save_post
if you would like to empty ALL cache on post save.
Maybe better to use transition_post_status