Created
May 16, 2020 15:41
-
-
Save tdtgit/9ff4c4e8af347111cf22e9425aff2405 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 | |
DOMAIN=$1 | |
scan_sitemap () { | |
[ -z "$1" ] && URL="https://$DOMAIN/sitemap.xml" || URL=$1 | |
curl -L --compressed $URL 2>/dev/null | grep -Eo "http(s?):\/\/$DOMAIN[^ \"\'()\<>]+" | while read line; do | |
if [[ $line = *.xml ]] | |
then | |
echo "๐ Sitemap $line" | |
scan_sitemap $line | |
else | |
if [[ $line =~ .*.(jpg|gif|png)$ ]] | |
then | |
image_warmup $line | |
else | |
url_warmup $line | |
fi | |
fi | |
done; | |
} | |
url_warmup () { | |
echo " ๐๏ธ Warming brotli $1" | |
curl -sSL -H 'accept-encoding: br' -A 'The Boring Cache Warmer' $1 -o /dev/null & | |
echo " ๐๏ธ Warming non-brotli $1" | |
curl -sSL -H 'accept-encoding: gzip' -A 'The Boring Cache Warmer' $1 -o /dev/null | |
echo -e " โ Done\n" | |
} | |
image_warmup () { | |
echo " ๐๏ธ Warming WEBP $1" | |
curl -sSL -H 'accept: image/webp,image/apng,image/*,*/*;q=0.8' -A 'The Boring Cache Warmer' $1 -o /dev/null & | |
echo " ๐๏ธ Warming non-WEBP $1" | |
curl -sSL -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -A 'The Boring Cache Warmer' $1 -o /dev/null & | |
echo -e " โ Done\n" | |
} | |
scan_sitemap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment