Skip to content

Instantly share code, notes, and snippets.


arianna-aondio aondio

View GitHub Profile
View Get YKeys from Origin server
varnishtest "Get YKeys from Origin server"
server s1 {
txresp -hdr "ykey: BOB TOM"
} -start
varnish v1 -vcl+backend {
import ykey;
View Synch two-tier CDN
VCP layer:
# Simply use caching headers. Nothing relevant here.
if beresp.http.X-VCP-Ttl > 0:
beresp.ttl = beresp.http.X-VCP-Ttl
beresp.grace = beresp.http.X-VCP-Grace
beresp.keep = beresp.http.X-VCP-Keep
# Let built-in VCL transform this in a HFM.
View Implement the x-accel header by Ngnix in Varnish
varnishtest "implementing x-accel-redirect"
server s1 {
expect req.url == "/s1"
txresp -hdr "X-Accel-Redirect: /s2"
expect req.url == "/s2"
} -start
View Serve from cache only if backend is not healthy
import std;
sub vcl_recv {
if (!std.healthy(req.backend_hint)) {
set req.grace = 4h;
sub vcl_backend_response {
View ESI subrequest retry
varnishtest "Cut off ESI request should be retried"
server s1 {
expect req.url == "/list"
txresp -body {<esi:include src="/fragment"/>}
expect req.url == "/fragment"
txresp -status 503
View Host based backend
sub vcl_recv {
if ( == "") {
set req.backend_hint = origin_t1_weiyuzw;
View VCL-static
vcl 4.0;
import http;
# We define the origin servers
# assumption they listen on port 80, please change it if not true
backend origin_a {
.host = "";
.port = "80";
View hash with sick backends
varnishtest "hash director with sick backend"
server s1 -repeat 2 {
expect req.url == "/s1"
expect req.http.Host == "host2"
txresp -hdr "Server: s1" -body "server1"
} -start
server s2 {
View ESI test
varnishtest ESI
server s1 {
txresp -body {
Before include
<!--esi <esi:include src=""/> -->
After include
View Sticky hashing
vcl 4.1;
import cookieplus;
import header;
import std;
import directors;
backend default {
.host = "";
.port = "8081";
You can’t perform that action at this time.