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.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | varnish-expire-wildcards-2169627-10.patch | 1.11 KB | Island Usurper |
Comments
Comment #1
mgiffordSeems 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.
Comment #2
frankkessler commentedI'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.
Comment #3
heivoll commented@frankkessler : That is a good point, but couldn't that be fixed with using
node/1234(without a wildcard) and alsonode/1234/*ornode/1234?*?Comment #4
cammchugh commentedThe patch no longer applies cleanly to 7.x-1.x-dev, here's an updated patch that does.
Comment #5
ttkaminski commentedPatch 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):
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.
Comment #6
Island Usurper commentedI'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.Comment #7
ttkaminski commentedPatch in #6 looks buggy. The ? needs to be escaped. Best to combine both into a single regex:
$paths[$path . '[/?](.*)'] = $path . '[/?](.*)';Comment #8
Island Usurper commentedOh, right.
Comment #9
misc commentedCould you please redo the patch, it does not apply anymore.
Comment #10
Island Usurper commentedSure.
Comment #11
les limThe patch is readable, well-formed, and effective. I've been using this in production for a couple sites.
Comment #12
candelas commentedPatch from #10 works. Thanks
Comment #13
misc commentedCommitted to latest dev (will be in beta5)
Comment #15
misc commentedCorrection - will be in 7-x.1.1