Simple script to pre-warm boost cache on a small site
Boost is a module that allows for static caching on a Drupal site for improving performance for anonymous users. You can read more about how to install and configure boost here. Boost comes with a boost crawler that can crawl your site and refresh the boost cache. Here is a simple script that can be used to refresh the boost cache without enabling the boost crawler.
#!/bin/bash
#usage: refresh-boost-cache.sh www.example.com lastnid
nid=$2
last_nid_file=$1.txt
if [ -e $last_nid_file ];
then
nid=$((`cat $last_nid_file`));
echo "Read $nid from file"
fi
while [ $nid -gt 0 ]
do
#echo "loading $nid"
wget -O - -q -t 1 "http://$1/node/$nid" > /dev/null
if [ "$last_nid_file" != "" ];
then
echo $nid > $last_nid_file
fi
#echo "$? returned"
nid=$[$nid-1]
sleep 5
done
You can save this file as refresh-boost-cache.sh in your home folder and add a cron job in your machine to run this script once every N days where N is the boost expiry set. You can increase the speed of this script by decreasing the time the script sleeps between requests in the penultimate line of the script. Do however note that decreasing the sleep time could have an adverse effect on the load on the server.