Skip to content

Instantly share code, notes, and snippets.

@rezan
rezan / multi_purge.vtc
Created September 11, 2019 18:14
Purge multiple URLs from a request body
varnishtest "Multipurging"
server s1 {
} -start
varnish v1 -vcl+backend {
import edgestash;
import synthbackend;
import xbody;
@rezan
rezan / streaming.txt
Created September 11, 2019 15:50
Streaming results before and after patching
BEFORE
[reza@77-40-251-104 ovc60]$ bin/varnishlog -g request -d -q "ReqHeader:hls-segment eq 1568214974" | grep Waiting
- Timestamp Waitinglist: 1568214974.765237 0.126271 0.126271
- Timestamp Waitinglist: 1568214974.765223 0.126131 0.126131
- Timestamp Waitinglist: 1568214974.765225 0.126174 0.126174
- Timestamp Waitinglist: 1568214975.642919 1.002913 1.002913
- Timestamp Waitinglist: 1568214975.642900 1.003035 1.003035
- Timestamp Waitinglist: 1568214975.642918 1.002753 1.002753
- Timestamp Waitinglist: 1568214975.642931 1.002935 1.002935
@rezan
rezan / stale_on_error.vcl
Last active August 30, 2019 13:00
Serve stale on error
#
# Stale-If-Error (v1.0)
#
import std;
sub vcl_recv {
# First pass, clear SIE headers
if (!req.restarts) {
unset req.http.x-sie6-enabled;
@rezan
rezan / esi_xbody_transform.vtc
Created June 5, 2019 00:13
Transform ESI to Edgestash using XBody
varnishtest "Transform ESI to Edgestash using XBody"
server s1 {
rxreq
txresp -body {
Start <esi:remove>
...
</esi:remove>
<!--esi <esi:include src="/somewhere" /> -->
@rezan
rezan / s3_v4_signing.vcl
Last active April 22, 2020 07:03
S3 v4 request signing in VCL
#
# S3 v4 request signing (v1.6)
#
import crypto;
import goto;
import kvstore;
import std;
import urlplus;
import utils;
@rezan
rezan / hash.vtc
Created May 8, 2019 15:57
Body hashing
varnishtest "Test xbody hash large body"
server s1 {
rxreq
txresp -bodylen 500000
} -start
varnish v1 -vcl+backend {
import crypto;
import xbody;
@rezan
rezan / log_set_cookie.vcl
Last active May 3, 2019 14:43
Log all set cookies to varnishncsa via %{set-cookie-log}o
@rezan
rezan / prefetch_live.vcl
Created April 18, 2019 00:06
Live prefetching
# Live prefetching
vcl 4.1;
import http;
import kvstore;
sub vcl_init
{
new limit = kvstore.init();
@rezan
rezan / backend_prefetch.vcl
Created April 17, 2019 17:53
Backend prefetch
# Backend prefetch
vcl 4.1;
import http;
sub vcl_recv {
// Generate the prefetch URL
set req.http.X-prefetch = http.prefetch_next_url(prefix = "/.*/dash/[0-9]+-[0-9]+/");
}
@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}";