Cache warming a website with Optimus Prime

Not all cache plugins or apps preload pages or provide a warm cache of all content, normally the first time a page is visited it is not cached but subsequent pages are. More plugins are providing pre-loading or warm cache solutions but some still don’t or web hosts don’t allow it – there are a couple of solutions, Warm Cache is one and Optimus Prime is another which is discussed below.

This guide is more cPanel focused, there is another cache warmer one for RunCloud.

Optimus prime is an binary executable app you install on your webserver so good if you have command line access, but also totally usable with cPanel ftp and a cron job. The program works by trawling the sites sitemap so the cache app starts to cache all the pages.

Download and extract it via Command Line

wget -c https://cdn.pmylund.com/files/tools/ocp2/linux/ocp-2.7-amd64.tar.gz -O - | tar -xz

Alias it

echo "alias ocp='~/ocp/ocp'" >> .bashrc
source .bashrc

Manual Download

You can also just choose to manually download it directly, (the Linux (64-bit) one will suit most webservers, extract it and move the inner ocp app to your web server, doing it this way you will have to re-apply execute permissions…

chmod +x ocp

Using it

ocp http://mysite.com/sitemap_index.xml

Or if you have it without alias use it from the directory you are in.

./ocp http://mysite.com/sitemap_index.xml

To see a list of available commands

./ocp

Adding as Cron Job

The example below is a cPanel cron job setting the command to run every 3 hours

Example Cron Capnel Optimus Prime

 

If you have large sites on a web server you may want to stop the ocp command from overlapping, this is possible using another script  from the same author one.sh , download here.

Change directory to your ocp directory and download it:

wget https://cdn.pmylund.com/files/tools/one/one.sh

Make it executable:

chmod +x ocp/one.sh

You can run it like so

one.sh ocp http://mysite.com/sitemap_index.xml

Optimus Prime home

WP Johnny Guide

Gridpane Docs