Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erikhansen/413b7876f2951ea16365dce0f1bffaf5 to your computer and use it in GitHub Desktop.
Save erikhansen/413b7876f2951ea16365dce0f1bffaf5 to your computer and use it in GitHub Desktop.
Varnish Dev Ops
# clear the entire cache
varnishadm "ban req.url ~ /"
# monitor varnish log with multiple patterns
varnishlog | grep 'eqURL\|Age:\|VCL_call\|TTL\|Expires:\|Cache-Control:'
# Use a query with varnishlog to watch requests from a specific IP
varnishlog -q 'ReqHeader:X-User-IP eq "1.2.3.4" or BereqHeader:X-User-IP eq "1.2.3.4"'
# Monitor PURGE requests hitting Varnish
varnishlog -n prod -q 'ReqMethod eq "PURGE"'
varnishlog -n prod -q 'ReqMethod eq "PURGE"' | grep 'X-Magento-Tags-Pattern\|X-Pool'
# determine the instance names of multiple varnish instances
ls -la /var/lib/varnish/
# use varnish log against a specific instance name
varnishlog -n stage
# purge request using curl from the local machine
curl -s -H 'X-Pool: prod' -X PURGE http://127.0.0.1:6081/
# Check config. If a syntax error exists it will produce an error, otherwise it will output the configuration
varnishd -C -f /etc/varnish/default.vcl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment