Skip to content

Instantly share code, notes, and snippets.

@rezan
rezan / grace.vcl
Last active February 5, 2016 18:19
Varnish 4 grace
# conditional grace for healthy/unhealthy (30s/1h)
vcl 4.0;
import std;
sub vcl_hit {
if (std.healthy(req.backend_hint) && obj.ttl + 30s < 0s) {
return(fetch);
}
@rezan
rezan / hit_miss.vcl
Last active October 8, 2015 14:00
add hit, miss, grace, keep, and ttl headers
vcl 4.0;
#put this near the top of the parent vcl:
#include "hit_miss.vcl";
sub vcl_hit
{
set req.http.X-status = "HIT";
set req.http.X-ttl = obj.ttl;
set req.http.X-grace = obj.grace;
@rezan
rezan / s3.vcl
Last active July 6, 2023 13:02
Varnish AWS S3 Gateway VCL
#
# Varnish AWS S3 Gateway VCL
#
# Allows global read (GET, HEAD) and ACL protected writes (POST, PUT, DELETE).
# When writing, pass in Content-Type and Content-MD5, both are optional.
#
# Params:
#
# %BUCKET% - S3 bucket name, S3 host may be regional
# %ACCESS_ID% - IAM access ID for bucket
@rezan
rezan / write_retry.vtc
Created March 4, 2016 01:51
Test case for retries
varnishtest "PUT/POST/DELETE retry"
server s1 {
rxreq
delay 0.5
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_backend_fetch {
@rezan
rezan / calc_memory.sh
Created March 4, 2016 16:01
Calculate unreferenced memory for a PID
#!/bin/bash
if [ "$1" = "" ]
then
echo "Pass in a PID"
exit 1
fi
SMAPS=/proc/$1/smaps
@rezan
rezan / code.c
Last active March 7, 2016 21:47
Code example
# this is a comment
int i = 0;
foo();
i++;
@rezan
rezan / cedexis.vcl
Last active July 6, 2016 00:41
Cedexis test objects local in Varnish Cache
/*
* Cedexis test object location: L34, L39
*
* Requires vmod null:
* https://github.com/varnish/libvmod-null
*
*/
vcl 4.0;
@rezan
rezan / edgestash_json.vcl
Created September 22, 2016 16:32
Edgestash VCL generated JSON variables
vcl 4.0;
# Edgestash
# VCL generated JSON variables
#
# /edgestash/test/1 template contents:
# Hello {{name}} {{test}}!
backend default
{
@rezan
rezan / m00026.vcl.c
Created November 9, 2016 21:49
C code for m00026.vtc (scoped object support)
/* ---===### include/vdef.h ###===--- */
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2012 Fastly Inc
* Copyright (c) 2006-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
* Author: Rogier 'DocWilco' Mulhuijzen <rogier@fastly.com>
@rezan
rezan / wordpress.vcl
Last active December 21, 2016 17:49
A generic Varnish Cache worldpress VCL template
# Worldpress Varnish Cache VCL template
# 12/21/2016
vcl 4.0;
backend wordpress {
.host = "0.0.0.0";
.port = "0";
}