6

I'm using Drupal 7 latest dev version.

I have installed Varnish and Expire modules and setup them. They are working very well but I have one problem regarding deleting cache from varnish.

The problem is how to delete varnish cache only for index(home) page and not to delete cache for other pages. I look at he varnish log and I found that whole varnish cache is deleted every time Drupal executes command

 ban req.http.host ~ www.cdm.me && req.url ~ "/"

This command is executed by varnish module or expire module and it means delete cache of home(index) page. But as I see it is deleting all cached pages in varnish.

How to fix this? How can I delete only cache for home page?

Danilo Puric
  • 779
  • 2
  • 13
  • 23

4 Answers4

15

You should invoke other command from Drupal:

ban req.http.host ~ www.cdm.me && req.url ~ "^/$"

Cache invalidated for whole site, because regexp "/" matches all URLs

ghloogh
  • 1,634
  • 16
  • 9
1

You could also do

ban req.http.host == www.cdm.me && ban req.url == "/"
hernandes
  • 371
  • 1
  • 5
  • 14
0

Will this Drupal Purge module do it for you? https://drupal.org/project/purge

Lee Woodman
  • 1,319
  • 2
  • 16
  • 30
0

There is the Varnish HTTP Accelerator Integration module, which provides a very useful function varnish_purge().

Use the function to clear the varnish cache.

milkovsky
  • 8,772
  • 4
  • 28
  • 32