> But if |$this->host| is a regex, how can we use it in |purge| and |refresh|?

true that. i come from the scenario we had in LiipCacheControlBundle where you did either ban or purge, never both. what i would propose is that we do the operations in the DI class and only inject the regexp (no value in doing the join and all that at runtime, it can be done at container compile time). the configuration then can have two options, hostName or hostPattern, and the DI does the right thing. we could even handle the situation where both are set by providing two services.

> Not setting empty regex headers is cleaner, but would make both our
> Varnish class and the Varnish configuration more complex. Would it help
> Varnish performance, though, to have simpler bans where possible?

its really an edge case, and i guess if host just does not matter (i.e. you only cache a single domain), you can always simply ignore it in the varnish rules. so agreed, lets keep it simple here and always provide the header.