Created
May 16, 2020 15:41
-
-
Save tdtgit/9ff4c4e8af347111cf22e9425aff2405 to your computer and use it in GitHub Desktop.
This file contains hidden or 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