Skip to content

Commit 7f4eb1a

Browse files
authored
Merge pull request #64 from elgentos/bfcache
#17 test bfcache
2 parents d2a7e10 + 2592029 commit 7f4eb1a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/varnish/bfcache.vtc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
varnishtest "BF cache test by loading the same page twice"
2+
3+
server s1 {
4+
# first request will be the probe, handle it and be on our way
5+
rxreq
6+
expect req.url == "/health_check.php"
7+
txresp
8+
9+
# the probe expects the connection to close
10+
close
11+
accept
12+
13+
rxreq
14+
expect req.url == "/"
15+
expect req.method == "GET"
16+
txresp
17+
18+
rxreq
19+
expect req.url == "/"
20+
expect req.method == "GET"
21+
txresp
22+
} -start
23+
24+
# Generate the VCL file based on included variables and write it to output.vcl
25+
shell {
26+
export s1_addr="${s1_addr}"
27+
export s1_port="${s1_port}"
28+
${testdir}/helpers/parse_vcl.pl "${testdir}/../../etc/varnish6.vcl" "${tmpdir}/output.vcl"
29+
}
30+
31+
varnish v1 -arg "-f" -arg "${tmpdir}/output.vcl" -arg "-p" -arg "vsl_mask=+Hash" -start
32+
33+
# make sure the probe request fired
34+
delay 1
35+
36+
client c1 {
37+
txreq -method "GET" -url "/"
38+
rxresp
39+
40+
txreq -method "GET" -url "/"
41+
rxresp
42+
expect resp.http.Cache-Control == "must-revalidate, max-age=60"
43+
} -run

tests/varnish/helpers/parse_vcl.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'GRACE_PERIOD' => '300',
1515
'SSL_OFFLOADED_HEADER' => 'X-Forwarded-Proto',
1616
'USE_XKEY_VMOD' => '1',
17+
'ENABLE_BFCACHE' => '1',
1718
'ENABLE_MEDIA_CACHE' => '1',
1819
'ENABLE_STATIC_CACHE' => '1',
1920
'ACCESS_LIST' => 'server1 server2',

0 commit comments

Comments
 (0)