Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-etag
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-etag
Commits
a520a58d
Unverified
Commit
a520a58d
authored
Apr 12, 2022
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make etag_esi.vtc the demo for the dynamic case based on obj.can_esi
parent
36bad311
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
11 deletions
+30
-11
etag_esi.vtc
src/vtc/etag_esi.vtc
+29
-10
etag_esi_pattern.vtc
src/vtc/etag_esi_pattern.vtc
+1
-1
No files found.
src/vtc/etag_esi.vtc
View file @
a520a58d
varnishtest "demo/test vmod-etag use for ESI assembled page caching"
varnishtest "demo/test vmod-etag use for ESI assembled page caching
(dynamic)
"
server s1 {
server s1 {
rxreq
rxreq
expect req.url == "/esi"
expect req.url == "/esi"
txresp -body {
<html><head>
head
</head>
txresp -hdr {Surrogate-Control: content="ESI/1.0"} \
-body {
<html><head>
head
</head>
<esi:include
src=
"/body"
/>
<esi:include
src=
"/body"
/>
footer
footer
</html>
}
</html>
}
rxreq
rxreq
expect req.url == "/body"
expect req.url == "/body"
txresp -body {Body Content}
txresp -
hdr {Etag: "123body"} -gzip
body {Body Content}
} -start
} -start
varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
import etag;
import etag;
import std;
# to adjust:
# to adjust:
# - url pattern to be handled ("^/esi")
# - beresp.ttl
# - beresp.ttl
# - beresp.grace - important because of do_stream
# - beresp.grace - important because of do_stream
...
@@ -27,15 +27,26 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
...
@@ -27,15 +27,26 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
}
}
sub hash_etagesi {
sub hash_etagesi {
if (local.socket != "self") {
if (req.restarts == 0 || local.socket == "self") {
unset req.http.etagesi;
return;
return;
}
}
if (req.http.etagesi) {
hash_data("etagesi");
}
}
hash_data("self");
sub deliver_etagesi {
if (obj.can_esi
&&
req.restarts == 0
&&
local.socket != "self") {
std.rollback(req);
set req.http.etagesi = "1";
return (restart);
}
}
}
sub backend_fetch_etagesi {
sub backend_fetch_etagesi {
if (
local.socket == "self" || bereq.url !~ "^/esi"
) {
if (
! bereq.http.etagesi
) {
return;
return;
}
}
...
@@ -44,7 +55,7 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
...
@@ -44,7 +55,7 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
}
}
sub backend_response_etagesi {
sub backend_response_etagesi {
if (
local.socket == "self" || bereq.url !~ "^/esi"
) {
if (
! bereq.http.etagesi
) {
return;
return;
}
}
...
@@ -69,10 +80,12 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
...
@@ -69,10 +80,12 @@ varnish v1 -arg "-a :0 -a self=${tmpdir}/self.sock" -vcl+backend {
sub vcl_backend_response {
sub vcl_backend_response {
call backend_response_etagesi;
call backend_response_etagesi;
set beresp.do_esi =
true
;
set beresp.do_esi =
beresp.http.surrogate-control ~ "ESI/1.0"
;
}
}
sub vcl_deliver {
sub vcl_deliver {
call deliver_etagesi;
set resp.http.hits = obj.hits;
set resp.http.hits = obj.hits;
}
}
} -start
} -start
...
@@ -94,4 +107,10 @@ client c1 {
...
@@ -94,4 +107,10 @@ client c1 {
footer
footer
</html>
}
</html>
}
txreq -url "/body" -hdr "Accept-Encoding: gzip"
rxresp
expect resp.status == 200
expect resp.http.hits == 1
expect resp.http.ETag == {"123body"}
} -run
} -run
src/vtc/etag_esi_pattern.vtc
View file @
a520a58d
varnishtest "demo/test vmod-etag use for ESI
assembled page caching
"
varnishtest "demo/test vmod-etag use for ESI
caching with url patterns
"
server s1 {
server s1 {
rxreq
rxreq
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment