Skip to content

Instantly share code, notes, and snippets.

@kaziqta
Forked from chales/cache-warmer-3.sh
Created November 1, 2016 11:20
Show Gist options
  • Save kaziqta/45b1bf37c8d64baec646035b32669b21 to your computer and use it in GitHub Desktop.
Save kaziqta/45b1bf37c8d64baec646035b32669b21 to your computer and use it in GitHub Desktop.
A couple of simple options to parse sitemap.xml to warm the cache or for other actions such as generating memory_profiler checks.
# This can be added to your cron job to run right after Drupal's cron or combine them into a single command so
# that it automatically executes when the cron run completes.
wget -q http://www.example.com/sitemap.xml -O - | egrep -o "http://www\.example\.com[^<]+" | wget -q -i - -O /dev/null --wait 1
#!/bin/bash
DOMAIN='example.com'
# One liner with wget. This can be used on the cli, just replace $DOMAIN with the domain directly.
wget -q http://$DOMAIN/sitemap.xml --no-cache -O - | egrep -o "http://$DOMAIN[^<]+" | wget --spider -i - --wait 1
#!/bin/bash
DOMAIN='www.example.com'
# wget and cURL
wget -q http://$DOMAIN/sitemap.xml --no-cache -O - | egrep -o "http://$DOMAIN[^<]+" | while read line;
do
time curl -A 'Cache Warmer' -s -L $line > /dev/null 2>&1
echo $line
done
# If you have multiple languages add another, e.g. http://$DOMAIN/es/sitemap.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment