Skip to content

#17 test bfcache #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/varnish/bfcache.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
varnishtest "BF cache test by loading the same page twice"

server s1 {
# first request will be the probe, handle it and be on our way
rxreq
expect req.url == "/health_check.php"
txresp

# the probe expects the connection to close
close
accept

rxreq
expect req.url == "/"
expect req.method == "GET"
txresp

rxreq
expect req.url == "/"
expect req.method == "GET"
txresp
} -start

# Generate the VCL file based on included variables and write it to output.vcl
shell {
export s1_addr="${s1_addr}"
export s1_port="${s1_port}"
${testdir}/helpers/parse_vcl.pl "${testdir}/../../etc/varnish6.vcl" "${tmpdir}/output.vcl"
}

varnish v1 -arg "-f" -arg "${tmpdir}/output.vcl" -arg "-p" -arg "vsl_mask=+Hash" -start

# make sure the probe request fired
delay 1

client c1 {
txreq -method "GET" -url "/"
rxresp

txreq -method "GET" -url "/"
rxresp
expect resp.http.Cache-Control == "must-revalidate, max-age=60"
} -run
1 change: 1 addition & 0 deletions tests/varnish/helpers/parse_vcl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'GRACE_PERIOD' => '300',
'SSL_OFFLOADED_HEADER' => 'X-Forwarded-Proto',
'USE_XKEY_VMOD' => '1',
'ENABLE_BFCACHE' => '1',
'ENABLE_MEDIA_CACHE' => '1',
'ENABLE_STATIC_CACHE' => '1',
'ACCESS_LIST' => 'server1 server2',
Expand Down