When purging URLs through the Expire module through the implementation of hook_expire_cache(), it does not currently take into consideration the $wildcards parameter that is sent by the Expire module. I've added a very basic patch for adding support for this. The wildcard will always just add a (.*) to the end of each path where wildcard is set to true.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgifford’s picture

Seems to apply fine when I applied it on simplytest.me - I haven't gotten to test this in a live environment, but looks like a good extension to allow for this use of the Expire module.

frankkessler’s picture

I'm trying to do something along these lines, but I'm wondering the best way to handle a different case. If "node/1234" needs to be cleared, I would also like to clear "node/1234?test=1", but I don't want to clear "node/12345". This patch would clear both, but since the expire module only sends over a boolean value for the wildcard, there isn't much that can be done on the varnish module side.

heivoll’s picture

@frankkessler : That is a good point, but couldn't that be fixed with using node/1234 (without a wildcard) and also node/1234/* or node/1234?* ?

cammchugh’s picture

The patch no longer applies cleanly to 7.x-1.x-dev, here's an updated patch that does.

ttkaminski’s picture

Patch in #4 worked for me.

@frankkessler, to purge urls along with all the ones that have query strings, I strip out the query string in the varnish vcl (sub vcl_fetch):

# For the purposes of banning, let's ignore the query string part
set beresp.http.x-url = regsub(beresp.http.x-url, "\?.*$", "");

Note, that I am using the Ban Lurker ban type, where ban rules are based off beresp.http.x-url and beresp.http.x-host.

Island Usurper’s picture

Status: Active » Needs review
FileSize
1.28 KB

I've changed the patch so that it works the way #3 mentioned, which I believe is more closely aligned with the way expire.module expects the wildcard to work. When a wildcard path comes in to varnish_expire_cache(), it adds two new versions of the path to the list, which have '/(.*)' and '?(.*)' added to it. Thus, the original path, all paths beneath it, and all query arguments are expired by specifying one wildcard path.

ttkaminski’s picture

Status: Needs review » Needs work

Patch in #6 looks buggy. The ? needs to be escaped. Best to combine both into a single regex:
$paths[$path . '[/?](.*)'] = $path . '[/?](.*)';

Island Usurper’s picture

Assigned: heivoll » Unassigned
Status: Needs work » Needs review
FileSize
1.24 KB

Oh, right.

MiSc’s picture

Status: Needs review » Needs work

Could you please redo the patch, it does not apply anymore.

Island Usurper’s picture

Status: Needs work » Needs review
FileSize
1.11 KB

Sure.

Les Lim’s picture

Status: Needs review » Reviewed & tested by the community

The patch is readable, well-formed, and effective. I've been using this in production for a couple sites.

candelas’s picture

Patch from #10 works. Thanks

MiSc’s picture

Status: Reviewed & tested by the community » Fixed

Committed to latest dev (will be in beta5)

  • MiSc committed 1b01e53 on 7.x-1.x authored by Island Usurper
    Issue #2169627 by Island Usurper, heivoll, cammchugh: No support for...
MiSc’s picture

Correction - will be in 7-x.1.1

Status: Fixed » Closed (fixed)

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