Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Seems with the latest dev-version (2011-Jul-22), the purge command is not working anymore.
I edit several nodes but the (old) nodes are still being served from cache.
When the cache expiration time is reached (10min in my setup), the edited nodes are finally visible.
Comment | File | Size | Author |
---|---|---|---|
#6 | varnish-1232448-6.patch | 1.44 KB | Dane Powell |
Comments
Comment #1
flatcircle CreditAttribution: flatcircle commentedAnd suddenly (after a reboot of the Varnish server) the purging is working again.
Comment #2
flatcircle CreditAttribution: flatcircle commentedStill experiencing problems.
After a while the purge command stops working.
I've setup a staging server a while ago and with an older version of the Varnish module, I have no problems.
7.x-1.x-dev - datestamp = "1307839269" => edit node => purge command to Varnish => working
7.x-1.x-dev - datestamp = "1311295316" => edit node => purge command to Varnish => broken
Comment #3
alexis CreditAttribution: alexis commentedI can confirm the problem exists in "7.x-1.x-dev" datestamp = "1311295316".
I compared with varnish.module for Drupal 6.x and there we had hook_comment and hook_nodeapi like:
Shouldn't the corresponding Drupal 7 hooks be added to fix this?
Comment #4
alexis CreditAttribution: alexis commentedI've fixed part of the problem. Sorry if I don't submit a patch in the proper way, I haven't had the time to read the docs for git yet.
You just need to add these functions to varnish.module:
This is the same approach used by the Varnish module for Drupal 6 and considers cases when a node or its comments change. I haven't considered the case for purging user profiles as I don't need that part for now but should be easy to add if you take a look at the 6.x module.
I'd prefer calling a function like this instead of purging all pages just because one node has changed:
but that adds some complexity to the logic as this code only purges the url where the full node is displayed but parts of a node, probably the teaser or title, can appear on other pages and those url's should be purged from Varnish as well.
I'm wondering if the module developers are thinking of a different approach and if that was the reason to remove this logic from the latest development code.
Comment #5
flatcircle CreditAttribution: flatcircle commentedAbsolutely right!
Indeed, the best way to send a purge command to Varnish is:
1) Only purge the node which has been modified
2) Purge additional nodes where content is also shown (teasers on frontpage, etc...)
Sending a purge command for all nodes when only 1 node has been modified is NOT recommended.
For example: you have a busy website with thousands of nodes and the website is being edited during the day by some editors/publishers.
This means the Varnish cache will be wiped constantly (because of the edits on nodes), resulting that almost no nodes are being served from Varnish because the cache has to be rebuild each time!
Comment #6
Dane Powell CreditAttribution: Dane Powell commentedHere's a patch based on #4- it's not an ideal solution, but it's better than nothing.
Comment #7
flatcircle CreditAttribution: flatcircle commentedWill this patch be included in future builds of the Varnish-module?
Comment #8
micheas CreditAttribution: micheas commentedShould the status be changed to needs review?
Or is the patch in post #6 ugly enough that a rewrite is needed?
Comment #9
fabsor CreditAttribution: fabsor commentedThis should not be needed in the Drupal 7 version. The new version works as a Drupal Cache backend, which means it will fetch all calls to cache_clear_all() automaticly. This means that the cache will be cleared automaticly by Drupal core.
If you need more granular cache invalidation, you can turn this feature off and build it yourself, or try the Expire module, which is supported by Varnish.
I ran the tests, and they indicate that everything should be working as they should. I also tried the module out by testing it manually and when it's properly configured, it works as expected. For information on how to set this up, see the project page.
I'm setting this to postponed, in case there was some use case I missed.
Comment #10
acouch CreditAttribution: acouch commentedI had this issue when varnish cron was enabled. This #1461792: Cache doesn't clear if "varnish_flush_cron" set to 1 fixed it.
Comment #11
Dane Powell CreditAttribution: Dane Powell commentedIt seems that in my case, this is my fault for not RTFM... I just needed to add Varnish as a caching backend as described in the README file:
Comment #12
MiSc CreditAttribution: MiSc commentedClosing issues that had no activity the latest year, please re-open if the issues is still relevant.