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.

CommentFileSizeAuthor
varnish_purge_custom_operator.patch1.42 KBLuxian
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Luxian created an issue. See original summary.

  • MiSc committed 6811716 on 8.x-1.x authored by Luxian
    Issue #2676500 by Luxian: Add support for custom operators inside...
MiSc’s picture

Status: Needs review » Fixed

Thanks, looks good, added to latest dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.