Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
After updating a site, it may be required to expire all pages. Should be done with care on sites with heavy traffic, but it would be great if we can do with a drush command or button in the admin.
I am using the following code for this (Varnish 3.x):
if (req.request == "PURGE" || req.request == "PURGEALL") {
if (!client.ip ~ purge) {
// Return error code 405 (Forbidden) when not
error 405 "Not allowed.";
}
if (req.request == "PURGE") {
// Purge all objects from cache that match the incoming url and host
ban("req.url == " + req.url + " && req.http.host == \"" + req.htt$
}
else {
// Purge all objects from cache that match the incoming host
ban("req.url ~ ^/ && req.http.host == " + req.http.host);
}
// Return a http error code 200 (Ok)
error 200 "Purged";
}
Comments
Comment #1
SqyD CreditAttribution: SqyD commentedHi maurits!
This feature request was expected and will be in a future release. Please see my comment on a similar feature request http://drupal.org/node/1299484#comment-5099470
Comment #2
SqyD CreditAttribution: SqyD commentedComment #3
sokrplare CreditAttribution: sokrplare commentedThe VCL excerpt was helpful, so just for future folks who come across this, we used similar VCL logic and then implemented the call to PURGEALL in a custom module. That module already integrated with the Cache Expiration (expire) module to give us a backend form where we could expire specific URLs if needed, but this extended it to purge the whole domain. If you don't have the expire module you'd probably want to use different link paths.
Comment #4
Grayside CreditAttribution: Grayside at Phase2 commentedI put together a Purge All module based on this issue. It wires up a Purge All option that can be configured for use by nodes.