I'm trying to make Varnish work on my local Mac with MAMP Pro (running a Drupal website). I have installed Varnish with Homebrew
brew install varnish
So far so good. Then I start Varnish with the following command :
sudo varnishd -a 127.0.0.1:8080 -T 127.0.0.1:6082 -f /usr/local/etc/varnish/drupal.vcl -s file,/tmp,500M
The varnish child start and I start to monitor with :
varnishstat
MAMP Pro is set to port 80 which is the conf I have in my .vcl file. The problem is Varnish does not cache the page when I go to my http://drupal.local website (All the caching conf from Drupal is properly set up as it works on a centOS server).
Any idea about what I'm missing ?
Best Answer
Here is the solution and what I was missing. My vhost was in HTTPS and working with Varnish it's easier to work with HTTP.
Here is all the step that might help someone :
Make sure that Apache in MAMP Pro is running on port 80.
In the VCL file make sure that Varnish targets port 80. Mine was looking like that :
Then I start varnish with the following command (varnish running on port 8080) :
When I visit
http://my-vhost.local:8080/node/1
varnish is properly caching the page. If I go tohttp://my-vhost.local/node/1
, I see the page without varnish.To clear the varnish cache of the page I just do this command :