Set up Cache Warming on RunCloud with Optimus Prime
Here is a tutorial on adding a cache warming tool: Optimus Prime on a RunCloud instance, your site will need to have an xml sitemap similar to the one provided by Yoast WordPress SEO.
RunCloud also has preloading as an option in their Runcache plugin, the Optimus Prime cache warmer can help when that is purged and speeds up all pages being primed and ready to go.
(There is a more Optimus Prime focused cPanel guide here).
Install Optimus Prime
Log in to your server via SSH and change directory to:
Get Optimus Prime and extract the archive:
wget -c https://cdn.pmylund.com/files/tools/ocp2/linux/ocp-2.7-amd64.tar.gz -O - | tar -xz
Use Optimus Prime manually
From the command line use:
Better Usage – Set Up a Cron Task
Log in to RunCloud control panel, choose your server and click Cron Job then click Create
Add in the command:
The user is runcloud adjust the command by swapping in your domain.
Then set your time, I use every 15mins
You can pick whatever frequency you like, cron guru can help with settings. Job done and cache constantly primed.
You can also set up the cron task on the command line.
Higher Frequency/Large Volume
Should you have a large site and/or want a real short interval for the command to run you may get multiple instances of the command running which cancel out what has been primed – there is an additional script option that allows the command to run uninterrupted. This script called one.sh is from the same developer.
Change into the ocp directory:
Get one.sh script:
Make it executable
chmod +x /usr/local/bin/ocp/one.sh
Now in your cron task change the command so one.sh controls ocp which queries the sitemap
/usr/local/bin/ocp/one.sh /usr/local/bin/ocp/ocp https://yourdomain.com/sitemap_index.xml
If your server is getting hammered you can restrict ocp usage by limiting the amount of pages it primes per minute, add a -c parameter followed by a number to set the amount of pages per minute.
So now your cron commands would be like so:
/usr/local/bin/ocp/one.sh /usr/local/bin/ocp/ocp -c 10 https://yourdomain.com/sitemap_index.xml
/usr/local/bin/ocp/ocp -c 10 https://yourdomain.com/sitemap_index.xml
That’s it – enjoy the speed.