-
-
Save mbarcia/cda5472b738f0a00dcfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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