- Issue created by @mandclu
- πΊπΈUnited States partdigital
Hi @madclu, thanks for reporting this!
Could you provide some more details? In theory the varnish cache should be clearing based on Tag invalidation.
I set up varnish on my ddev instance (based on ddev and drupal β documentation) and it seems to be working mostly as expected.
These are the steps that I followed:
Environment:
Install varnish:
ddev get ddev/ddev-varnish
Added this to .ddev/varnish/default.vcl
if(req.method == "BAN") { if (req.http.Purge-Cache-Tags) { ban("obj.http.Purge-Cache-Tags ~ " + req.http.Purge-Cache-Tags); } }
Modules:
Install the purge and purge_purger_http modules.Drupal Settings:
Set caching to 1 yearSet my purge settings as follows:
- Type: Tag
- hostname: varnish
- port: 80
- Headers: Purge-Cache-Tags = [invalidation:expression]
While interacting with a node as an anonymous user I see headers like this:
- 403 with policy: X-Varnish: 4751707 (miss)
- Refresh: X-Varnish: 2064725 (miss)
- 200 without policy: X-Varnish: 2064725 (miss)
- Refresh: X-Varnish: 5898824 3572108 (hit)
- 200 with policy: X-Varnish: 950757 (miss)
- Refresh : X-Varnish: 3801793 721458 (hit)
So the 200 responses seem to be hitting varnish while the 403 responses are missing varnish (warrants further investigation). In every case however it's showing the correct content.
Of course every environment is different so if you could share any addition details it would be much appreciated!
- π¨π¦Canada mandclu
Thanks for the very detailed response. I was doing my testing in an Acquia Cloud environment, and the site had the Purge and Acquia Purge modules installed. That said, it was using the alpha8 release of this module, so I will test with the beta1 release and report back.
- πΊπΈUnited States partdigital
@mandclu, are you still experiencing any issues with Varnish?
- Status changed to Closed: outdated
over 1 year ago 12:41pm 14 September 2023 - π¨π¦Canada mandclu
It seems as though the Varnish cache is properly invalidated since I've moving to a beta version. Thanks again for this great module!
- π«π·France dydave
Hi Joshua (@partdigital),
Just wanted to thank you very much for your great help with the configuration of the purge module at #2.
It works great !
What I could't figure out was the port number... since Varnish in our setup ('dev', 'stage', 'preprod', 'prod') is behind a HAProxy service so it's listening on the default port which is usually6081
, but I "suppose" that since it's in direct access on the local ddev stack, it's listening on port 80.
Here's a doc I found on Varnish port 80:
https://varnish-cache.org/docs/trunk/tutorial/putting_varnish_on_port_80...When I have some time, I'll try to add a documentation page in the Purge module for the Varnish setup on ddev, which will most likely re-use most of your comment above #2.
Once again, thanks a lot for your help and contribution !