Delete Cached Pages from Another System Pro
A deployment script, a publishing tool or another site can tell JCH Optimize to delete cached pages, so visitors get the new pages straight away. It sends your site one of two requests:
-
delete every cached page;
-
delete the cached versions of the pages whose addresses it lists, up to 100 in a request.
Either one also deletes the pages' static files (Serve Cached Pages as Static Files) and clears them at Cloudflare when Enable Cloudflare Purge is on. The combined CSS and JavaScript files are kept: only removes those.
The request is made in the name of one of your site's users, who must be allowed to clear the cache. Create a user for this rather than using your own account, so you can switch it off without locking yourself out.
- Joomla
-
JCH Optimize uses Joomla's Web Services. Installing the Pro package enables the Web Services - JCH Optimize plugin, which adds the two addresses below.
-
Choose the user. They need Web Services Login in → → , and JCH Optimize's Access Administration Interface and Clear Cache permissions (see the section called “Permissions Tab”). Super Users have all three.
-
Edit the user in → , and on the Joomla API Token tab set Active to Yes and save. Open the tab again and copy the Token. If the tab isn't there, the user's group isn't in the Allowed User Groups of the User - Joomla API Token plugin, which allows only Super Users by default.
-
Send the requests with the token in an
X-Joomla-Tokenheader. To delete every cached page:$curl -X DELETE -H "X-Joomla-Token:token"https://www.example.com/api/index.php/v1/jchoptimize/pagecacheTo delete the cached versions of two pages:
$curl -X POST -H "X-Joomla-Token:token" -H "Content-Type: application/json" -d '{"urls":["https://www.example.com/blog","https://www.example.com/blog/my-article"]}'https://www.example.com/api/index.php/v1/jchoptimize/pagecache/purge
The answer is a JSON document. For the listed pages, its
data.attributes.purgedis the number of cached versions that were deleted; for every page,data.attributes.deletedistrue.To switch this off, disable the Web Services - JCH Optimize plugin, or set the user's token to inactive.
-
- WordPress
-
JCH Optimize adds two addresses to WordPress's REST API.
-
Choose the user. They must be able to clear the page cache: an Editor or an Administrator, or a user given the
jch_clear_page_cachecapability with a role editor plugin. -
Edit the user in → , and under Application Passwords enter a name, click and copy the password. WordPress shows it only once.
-
Send the requests with the user's name and the application password. To delete every cached page:
$curl -X DELETE --user "username:application password"https://www.example.com/wp-json/jch-optimize/v1/page-cacheTo delete the cached versions of two pages:
$curl -X POST --user "username:application password" -H "Content-Type: application/json" -d '{"urls":["https://www.example.com/blog/","https://www.example.com/my-post/"]}'https://www.example.com/wp-json/jch-optimize/v1/page-cache/purge
The answer is JSON:
{"urls": [...], "purged": 2}for the listed pages, wherepurgedis the number of cached versions that were deleted, and{"deleted": true}for every page.To switch this off, revoke the application password on the user's profile.
-
Give each page's full address, starting with http:// or
https://. A page's cached versions are found by its path, so one address covers the
page on every host name and scheme your site answers to, and its paginated versions. A
purged of 0 means the page wasn't in the cache, which isn't an error.
On This Page