-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from duffn/duffn/include-exclude
Add include and exclude convenience functions
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
varnishtest "Test querymodifier vmod for proper exclusion of matching parameters using the excludeparams function" | ||
|
||
server s1 { | ||
rxreq | ||
txresp -body "OK1" | ||
expect req.url == "/feed/" | ||
|
||
rxreq | ||
txresp -body "OK1" | ||
expect req.url == "/blog?before_date=2024-11-23T00%3A00%3A00.000Z" | ||
} -start | ||
|
||
varnish v1 -vcl+backend { | ||
import std; | ||
import querymodifier; | ||
|
||
sub vcl_hash { | ||
std.syslog(180, "querymodifier before: " + req.url); | ||
set req.url = querymodifier.excludeparams(url=req.url, params="ts,v,date"); | ||
std.syslog(180, "querymodifier after: " + req.url); | ||
} | ||
} -start | ||
|
||
client c1 { | ||
txreq -url "/feed/?ts=1730210988319" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
# This one will be cached as all of the query params are excluded. | ||
txreq -url "/feed/?ts=1730210988319&v=1730210988319&date=1730210988319" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
txreq -url "/blog?ts=1730210988319&v=1730210988319&date=1730210988319&before_date=2024-11-23T00%3A00%3A00.000Z" | ||
rxresp | ||
expect resp.status == 200 | ||
} -run | ||
|
||
varnish v1 -expect n_object == 2 | ||
varnish v1 -expect cache_miss == 2 | ||
varnish v1 -expect cache_hit == 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
varnishtest "Test querymodifier vmod for proper inclusion of matching parameters using the includeparams function" | ||
|
||
server s1 { | ||
rxreq | ||
txresp -body "OK1" | ||
expect req.url == "/feed/?q=search" | ||
|
||
rxreq | ||
txresp -body "OK1" | ||
expect req.url == "/blog?id=1234&q=search" | ||
} -start | ||
|
||
varnish v1 -vcl+backend { | ||
import std; | ||
import querymodifier; | ||
|
||
sub vcl_recv { | ||
std.syslog(180, "querymodifier before: " + req.url); | ||
set req.url = querymodifier.includeparams(url=req.url, params="q,id"); | ||
std.syslog(180, "querymodifier after: " + req.url); | ||
} | ||
} -start | ||
|
||
client c1 { | ||
txreq -url "/feed/?q=search" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
# This one is cached as `ts` is excluded. | ||
txreq -url "/feed/?q=search&ts=123456789" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
txreq -url "/blog?id=1234&ts=1730210988319&v=1730210988319&date=1730210988319&q=search" | ||
rxresp | ||
expect resp.status == 200 | ||
} -run | ||
|
||
varnish v1 -expect n_object == 2 | ||
varnish v1 -expect cache_miss == 2 | ||
varnish v1 -expect cache_hit == 1 |