Varnish for multiple magento sites

Guillaume Quintard guillaume.quintard at gmail.com
Tue Jul 11 15:09:05 UTC 2023


Hi Ricardo,

Having your VCL (even anonymized) would help here, otherwise debugging is
pretty hard. For the moment, I'm going to assume you are using a variation
of
https://github.com/magento/magento2/blob/13e54e1b28a5d590ab885bd4df9f58877b549052/app/code/Magento/PageCache/etc/varnish6.vcl
and deal in generalities.

The way that vcl invalidates content is through bans:
https://github.com/magento/magento2/blob/13e54e1b28a5d590ab885bd4df9f58877b549052/app/code/Magento/PageCache/etc/varnish6.vcl#L30-L47
which doesn't need the host header, it's just uses unique tags pushed by
the backend in response headers.
If it was using the actual purge mechanism, then modifying the host should
be sufficient because purge acts on the object found in the cache (and if
you can get a hit, you can get purged).

Here's a good primer on invalidation:
https://docs.varnish-software.com/tutorials/cache-invalidation/

Kind regards,



-- 
Guillaume Quintard


On Tue, Jul 11, 2023 at 4:14 AM Riccardo Brunetti <riccardo.brunetti at host.it>
wrote:

> Hello.
> I'm new to varnish and I have a question concerning how to manage multiple
> sites using the same varnish cache frontend.
>
> More specifically, I need to setup a single varnish cache server for two
> different Magento2 sites.
>
> Looking around I found that it is possible to manage different backends
> using something like:
>
> if (req.http.host == "somesite") {
>         set req.backend_hint = somebackend;
>     }
>
> Now, I have two different Magento2 sites and, using the above expression,
> I can handle the two different backends.
> The problem is that I can't understand how to handle the PURGE/BAN of the
> two independently.
>
> As far as I understand from the .vcl file that Magento2 itself produces
> there is nothing inside the "purge" section that specifies which resources
> must be purged.
> It seems to me that is site A performs a purge, than also the cache of
> site B resources will be cleaned.
>
> Can you help me with this or point me to some example or tutorials?
>
> Thanks a lot
> Riccardo
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20230711/8070218c/attachment.html>


More information about the varnish-misc mailing list