Clear varnish cache with capistrano
A simple example, how to flush varnish cache with capistrano 3.
namespace :varnish do
set :varnish_auth, "/etc/varnish/secret"
set :varnish_address, "127.0.0.1:6082"
set :varnishadm, "/usr/bin/varnishadm"
desc 'Flush entire cache'
task :flush_all do
on roles(:web) do
execute "#{fetch(:varnishadm)} -T #{fetch(:varnish_address)} -S #{fetch(:varnish_auth)} ban \"req.url ~ ^/\""
end
end
desc 'Flush assets cache'
task :flush_assets do
on roles(:web) do
execute "#{fetch(:varnishadm)} -T #{fetch(:varnish_address)} -S #{fetch(:varnish_auth)} ban \"req.url ~ ^/assets/\""
end
end
end
Written by Victor Ortiz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#