Skip to content

Instantly share code, notes, and snippets.

@rezan
rezan / probe_interval.vtc
Last active April 16, 2019 23:26
Probe interval logging
varnishtest "Log probe activity across different intervals"
server s1 -repeat 31 {
rxreq
txresp
} -start
varnish v1 -vcl {
backend b1 {
.host = "${s1_addr}";
@rezan
rezan / object_fini.vtc
Created April 3, 2019 15:31
Object init() and fini()
varnishtest "Object init() and fini()"
server s1 {
} -start
varnish v1 -vcl+backend {
import debug;
sub vcl_init {
if (true) {
@rezan
rezan / xbody_hash.vtc
Created April 1, 2019 13:35
Resp body hashing with xbody
varnishtest "Resp body hashing"
server s1 {
rxreq
txresp -body "ABC 123"
expect req.url == "/1"
rxreq
txresp -body "test!"
expect req.url == "/2"
@rezan
rezan / gunzip_streaming.vtc
Created February 13, 2019 00:52
When you gunzip a streaming response, you can race on OA_GZIPBITS
varnishtest "VDP gunzip OA_GZIPBITS streaming race"
# Note this should run with -j64 -n10000
server s1 -repeat 50 {
rxreq
txresp -gziplen 3167
} -start
varnish v1 -vcl+backend {
@rezan
rezan / sick_backend.vtc
Created February 11, 2019 16:44
Mark a backend as sick using VCL
varnishtest "Temporary sick backends"
server s1 {
rxreq
txresp
rxreq
txresp
} -start
varnish v1 -vcl+backend {
@rezan
rezan / crypto_cookies.vtc
Created February 11, 2019 16:24
AES cookies
varnishtest "AES cookies"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import cookieplus;
import crypto;
@rezan
rezan / grpc.vcl
Last active January 17, 2019 15:16
Varnish GRPC VCL
# GRPC VCL
vcl 4.0;
import bodyaccess;
import http;
import std;
import synthbackend;
backend default {
@rezan
rezan / hfm.vtc
Created November 29, 2018 18:44
Test hit for miss (6.0)
varnishtest "Test hit for miss (6.0)"
server s1 -repeat 5 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.uncacheable = true;
@rezan
rezan / cache_tags.vcl
Created November 15, 2018 20:21
Drupal 8.0 cache tags implemented as xkey
#
# Drupal 8.0 cache tags implemented as xkey
#
# https://www.drupal.org/docs/8/api/cache-api/cache-tags-varnish
#
vcl 4.0;
import xkey;
@rezan
rezan / vmod_caps.vtc
Created November 8, 2018 20:11
Using CAPS for a VMOD
varnishtest "Test vmod in caps"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import std;