What is WP-CLI?
One of the command-line tools designed exclusively for managing WordPress websites is WP-CLI. You may manage WordPress with only a few straightforward commands, eliminating the need to log in to your WordPress admin area and navigate through your pages.
In most cases, you can automate your processes and purge, invalidate, and warmup pages in a specific time frame. CRON jobs can be utilized to do that.
A CRON job is a job scheduler for Unix-like operating systems, to put it simply. This allows users to plan tasks (commands or shell scripts) to run on a regular basis at predetermined times, dates, or intervals.
WP-CLI and NitroPack: Supported Operations
For WP-CLI, NitroPack supports the following commands:
- Connect NitroPack
wp nitropack connect
- Disconnect NitroPack
wp nitropack disconnect
- Do a full cache purge
wp nitropack purge
- Purge the cache for a specific URL
wp nitropack purge --purge-url=<URL>
- Invalidate the cache for the entire website
wp nitropack invalidate
- Run our Cache Warmup
wp nitropack warmup
Example Commands and Automation
One of the most useful commands that we can offer is for purging the cache for a specific URL.
This is great if you want to refresh the cache more frequently for specific pages only.
For example, purging a specific page:
wp nitropack purge --purge-url=https://domain.com/page
This can also be automated in a CRON job, say once every 24 hours:
0 0 * * * /path/to/wp-cli/wp --path=/path/to/your/website nitropack purge --purge-url=https://domain.com/page
You could also automate a full cache purge to be executed every 7 days:
0 0 * * 0 /path/to/wp-cli/wp --path=/path/to/your/website nitropack purge
The paths in the CRON job need to be adjusted based on where WP CLI is installed on the server and the path to your website.
Your hosting provider can help you obtain these paths, as well as set up the CRON job.
📌If you need any assistance or have questions, you can always reach out to our support team at email@example.com or via this link: https://support.nitropack.io/hc/en-us/requests/new
Please sign in to leave a comment.