By default module takes cache key and appends base path (/) to it, i suppose it's because varnish needs url without host name to purge cache. But to clear cache in Drupal database, we need to create full URL as key. So when we change cache backend, it won't work in the same way.

Currently i use something like this to make it work:

  if (variable_get('cache_class_cache_page', 'DrupalDatabaseCache') == 'VarnishCache') {
    $cid = drupal_get_path_alias("node/$nid");
  }
  else {
    $cid = url("node/$nid", array('absolute' => FALSE));
  }
  cache_clear_all($cid, 'cache_page');

Unfortunately i can't clear homepage with this code...

I suggest to use same key as for database and process it in the varnish cache interface, by removing host name from the provided cache key.
for example:
"http://sitename.com/some-url-alias" => should be changed to "/some-url-alias" for clearing particular page
"http://sitename.com/" => should be changed to "/" for clearing homepage

if some pattern was entered, like "*" or "." not sure what is correct for varnish... then it should also work ok, as we don't have host name in the pattern and it won't be affected.

Please let me know what do you think of this.
Module is very helpful and i really need it in my project, so if you consider these changes valuable I could help with creating a patch.

Thanks,
Dmitry

Comments

bibo’s picture

Added related issues. Pretty different titles, but they are connected to usage of hostname in purging/banning.

misc’s picture

Status: Active » Closed (outdated)