In admin/settings/varnish, setting 'Drupal Default' as the setting for Varnish Cache Clearing says that "Drupal default will clear all page caches on node updates and cache flush events". Does this mean that if hypothetically you have a million nodes, and half of those (500,000) are currently cached in Varnish, and someone updates a single node by going to the edit page, then the entire cache of 500,000 nodes in Varnish will be flushed? Is this actually the default behaviour?! If so I'm shocked.
So I enabled the Expire module which added an option 'Selective (experimental; uses expire.module)' - I'm assuming this means that if you update a single node then only THAT node will be flushed from Varnish, not all 500,000 nodes. Am I correct? If so, that's great - but it says experimental so I'm wondering for your input on what sites that are currently in production should be using? (I'm surprised the Expire module isn't part of the Varnish module because this module seems pretty incomplete without it...) The 'None' option doesn't work, the 'Selective' option being experimental doesn't suffice for a live production environment, and for a site with regular updates to nodes the 'Drupal Default' option removes any gains from Varnish. So I'm really not certain what to do.
If my interpretation of the above is correct (is it?), then it looks like I'll have to select the 'None' option and custom code my cache clearing logic as stated in the tip on that admin page - "None will allow pages to persist for their full max-age; use this if you want to write your own cache-clearing logic." If this is the case, how can I get started on writing this. Would I for example clear the cache for a given node in the update operation of hook_nodeapi? If so, what API methods in this module would I need to call to clear the cache for just that node? If someone could point me in the right direction that would be wonderful. Thank you very much.
Comments
Comment #1
fabsor commentedHi!
By default, the Varnish module mimics the default behaviour of Drupal, which means it will purge the full cache, potentially containing a lot of nodes, from the cache when a node is updated/created/deleted. While this might be catastrophic for big sites with a lot of traffic, it actually does the trick pretty well from smaller sites.
The support for expire isn't really experimental in my opinion, we should probably remove that wording. Expire was in dev for a long time and hence the experimental warning. We (NodeOne) are running quite a lot of bigger sites with expire module on with great success, and I would recommend on using it.
Using the none option implies that you will have to write your own purging logic or use something like Cache actions to purge your cache. you can use the varnish_expire_cache function to purge elements from varnish pretty easily.
Comment #2
regilero commentedI've submitted another bug #1362576: Logic to abort cache clear not working as expected about the none option. But as stated in this issue none IS doing a PURGE.
Comment #3
fabsor commentedThere is indeed a bug regarding this issue. I posted a patch in #1362576: Logic to abort cache clear not working as expected.
Comment #4
misc commentedAs a part of a clean up of the issue queue for the varnish module I am closing tickets that had no activity for the last year, please feel free to re-open if needed.