Created
May 23, 2013 11:21
-
-
Save vortizhe/5635377 to your computer and use it in GitHub Desktop.
Script to purge varnish specific url
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 | |
cmd="sudo varnishadm -T localhost:6082 -S /etc/varnish/secret" | |
page=$(echo $1 | awk -F'/' -v OFS='/' '{sub(/https?:\/\//, ""); $1=""; print $0}') | |
if [ -z "$1" ]; then | |
echo "ERROR: please provide a URL to ban.." | |
exit 1 | |
fi | |
if [ -z "$page" ]; then | |
page="/" | |
fi | |
echo "purging old version from cache.." | |
$cmd "ban req.url ~ ^$page\$" | sed '/^$/d' | |
echo "populating cache with new page content.." | |
curl -sL -w "%{http_code} %{url_effective}\n" http://tudomain${page} -o /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment