Skip to content

Instantly share code, notes, and snippets.

@mbarcia
Forked from thomasfr/warmly.sh
Last active August 29, 2015 14:23
Show Gist options
  • Save mbarcia/cda5472b738f0a00dcfa to your computer and use it in GitHub Desktop.
Save mbarcia/cda5472b738f0a00dcfa to your computer and use it in GitHub Desktop.
#!/bin/bash
# warmly.sh
# A wget based, easy, poor man`s cache warmer script
# Originally forked from
# https://gist.github.com/thomasfr/7926314
# No trailing slash
WARMLY_START_URL="${1}"
if [ -z $WARMLY_START_URL ]; then
echo "No starting URL set"
exit 1
fi
# Choose CWD
cd /root
# Strip protocol from starting URL
WARMLY_DIR="${WARMLY_START_URL#*//}"
# Remove any previous contents for a fresh start
rm -fr "/root/${WARMLY_DIR}"
# timestamping mimics real browsers behavior and speeds up the process by
# skipping resources as instructed by the webserver
# page-requisites mimics real browsers behavior by downloading resources,
# warming up Varnish cache
# level=2 allows for a quick pass, as the cache should be reasonably "warm"
# retries should not happen but just in case are here, as well as timeout
wget --recursive --timestamping --page-requisites --level=2 --tries=3 --timeout=20 "${WARMLY_START_URL}"
if [ $? -gt 0 ] ; then
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment