Closed (duplicate)
Project:
Varnish
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Jan 2014 at 11:41 UTC
Updated:
3 Jul 2017 at 07:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
thewilkybarkid commentedComment #2
bibo commentedI'd like to add an alternative approach to this problem. I encountered the problem when using cdn-module to offer static files over different domain. In some cases I wanted the static files to be cleared in sync with the rest of the site.
I solved it by actually just ignoring the domain/alias-specific part of the Varnish purge, in a custom drush extension. If I recall correctly, and earlier version of the Varnish module didn't even care about the hostname-part, but flushed just based on the path, or internal url. It was added later to increase hitrates in some scenarios - such as when there are multiple different sites behind the same Varnish instance. It depends on the use case if that is necessary at all.
In my case I just used an internal function of varnish-module, to run this:
In essence it would be the same as running the purge through varnish_purge() where "req.http.host ~ $host &&" has been removed (+ the same for ban lurker version).
An option to choose if the purges are limited to the hostname of the active Drupal-installation could be added to the admin settings. Apart from settings form (and documentation of this option), this would only require a few lines in varnish_purge()-function to work globally.
EDIT: replaced some "\"-escaping with ', to avoid problems with drupal.org PHP-filter.
Comment #3
bibo commentedI forgot to add that
$pattern = '/';would work just as well as$pattern = '.*';to flush everything, because "/" matches all paths (with the logic of Varnish).Comment #4
bibo commentedThis issue or rather it's solution may be a partial duplicate of an earlier issue, with a slightly more cryptic title: #1847672: VarnishCache::clear() has different behaviour than DrupalDatabaseCache::clear()..
I'm not marking this as a duplicate just yet (if someone agrees though, please change the status). I'm linking to here in a comment from the other issue.
Comment #5
bibo commentedComment #6
JeremyFrench commentedTrying to clean these issues into one #2208329: Support Multi domain sites
Comment #7
JeremyFrench commentedComment #8
miroslavbanov commentedPatch #1 works for me, but adding a new patch that keeps the
_varnish_get_host()function for backwards compatibility. Other modules may be using it, and it is still being called in some situation from varnish.cache.incComment #9
rkostov commentedpurge-site-aliases-2185281-9.patch is the same as #8 but compatible with the stable version 7.x-1.4