Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Varnish cache - How to purge/delete cache only for Home page

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?

like image 274
Danilo Puric Avatar asked Nov 24 '12 20:11

Danilo Puric


1 Answers

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

like image 81
ghloogh Avatar answered Nov 02 '22 22:11

ghloogh