In Mac OS X High Sierra or later version, let's say you upgraded Varnish HTTP Accelerator from 4.x.x/5.x.x to any latest versions 6.x.x using brew. And now for any reasons you want to go back to previous version i.e. 5.2.0 altogether? Good news folks!
You can do that by copying over the actual brew formulae on your local and defining the version you want in the rb file.
In the following example, I want to revert to version 5.2.0 from 6.2.0.
Let's copy over the file from https://github.com/Homebrew/homebrew-core/blob/master/Formula/varnish.rb to your local. Then edit the varnish.rb file, remove/comment out the following lines:
sha256 "c37af353aca25a83d22f9c5ce0ae800fe433e4d02e1457e02886a5849f988e53" bottle do sha256 "7101ff2895f77803ea1e1ca6c8ebc1feef2c07b77fbf612f6dcf6983bf4ffc27" => :mojave sha256 "d1fd8751be2ddccb463b385377b88cc440632eb1a07c0175fab9ee77c57f986d" => :high_sierra sha256 "e124ad1c5638c7304743b5f3dbec996afa33c972dbe991ec35280c4d7787b3a4" => :sierra end
Replace this line:
You can get all available versions in https://varnish-cache.org/releases/. All you need to do is to tap on the intended version and paste the download url.
Now, save this varnish.rb file and run:
chmod 775 varnish.rb brew install ./varnish.rb
brew will execute this and install varnish 5.2.0 as expected.