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.
There is no easy way to ban everything except static files (js, css, images), but this can be easily implemented if varnish_purge() would support custom operator for matching patterns.
With this patch applied you will be able to achieve this by using something as simple as that:
$pattern = '(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|svg)(\?.*)?$';
$pattern = str_replace('\\', '\\\\', $pattern); // escape the pattern
varnish_purge(_varnish_get_host(), $pattern, '!~');
The patch is made against 8.x-1.x branch, but I think it can be easily ported to D7 as well.
Comment | File | Size | Author |
---|---|---|---|
varnish_purge_custom_operator.patch | 1.42 KB | Luxian |
Comments
Comment #3
MiSc CreditAttribution: MiSc at Wunder commentedThanks, looks good, added to latest dev.