Skip to content

Instantly share code, notes, and snippets.

@flusher
Created May 2, 2014 16:18
Show Gist options
  • Save flusher/8bd1189b142dbb8fd57c to your computer and use it in GitHub Desktop.
Save flusher/8bd1189b142dbb8fd57c to your computer and use it in GitHub Desktop.
Website cache warmer from multipages XML sitemap
#!/bin/bash
# Warm cache from XML sitemap with multiple pages
url="www.example.com"
xmlsitemap="sitemap.xml"
pages=2
log_file="/var/log/cache_warmer.log"
echo $(date +"[%d/%m/%Y : %T]") "Cache warmer launched for $url" >> $log_file
for p in `seq $pages`
do
wget -q --no-cache "http://$url/$xmlsitemap?page=$p" -O - |
egrep -o "http://$url[^<]+" |
while read line; do
curl -A 'Cache Warmer' -s -L $line > /dev/null 2>&1
echo $line >>$log_file
done
done
echo $(date +"[%d/%m/%Y : %T]") "Cache warmer ended for $url" >> $log_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment