Skip to content

Commit

Permalink
Merge pull request #12 from sys0dm1n/user-agent
Browse files Browse the repository at this point in the history
Follow rfc7231 for the User-Agent string
  • Loading branch information
sys0dm1n committed Feb 7, 2019
2 parents b690716 + 024d8f5 commit 9fde760
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions varnish-cache-warmer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
# The URLs or IPs variables are passed as an argument to the script like below:
# ./varnish-cache-warmer.sh example1.com example2.com example3.com

VERSION='1.0.0'
USER_AGENT="VarnishCacheWarmer/$VERSION (see https://github.com/sys0dm1n/varnish-cache-warmer)"

warm_varnish() {
echo "Warming cache for $1"
curl -sL -A 'Cache Warmer' http://$1/sitemap.xml | egrep -o "http(s?)://$1[^ \"\'()\<>]+" | while read line; do
curl -sL -A "$USER_AGENT" http://$1/sitemap.xml | egrep -o "http(s?)://$1[^ \"\'()\<>]+" | while read line; do
if [[ $line == *.xml ]]
then
newURL=$line
curl -sL -A 'Cache Warmer' $newURL | egrep -o "http(s?)://$1[^ \"\'()\<>]+" | while read newline; do
time curl -sL -A 'Cache Warmer' -sL -w "%{http_code} %{url_effective}\n" $newline -o /dev/null 2>&1
curl -sL -A "$USER_AGENT" $newURL | egrep -o "http(s?)://$1[^ \"\'()\<>]+" | while read newline; do
time curl -sL -A "$USER_AGENT" -sL -w "%{http_code} %{url_effective}\n" $newline -o /dev/null 2>&1
echo $newline
done
else
time curl -sL -A 'Cache Warmer' -sL -w "%{http_code} %{url_effective}\n" $line -o /dev/null 2>&1
time curl -sL -A "$USER_AGENT" -sL -w "%{http_code} %{url_effective}\n" $line -o /dev/null 2>&1
echo $line
fi
done
Expand Down

0 comments on commit 9fde760

Please sign in to comment.