Skip to content

Instantly share code, notes, and snippets.

@rezan
rezan / grace.vcl
Last active Feb 5, 2016
Varnish 4 grace
View grace.vcl
# 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 Oct 8, 2015
add hit, miss, grace, keep, and ttl headers
View hit_miss.vcl
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 Aug 19, 2019
Varnish AWS S3 Gateway VCL
View s3.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 Mar 4, 2016
Test case for retries
View write_retry.vtc
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 Mar 4, 2016
Calculate unreferenced memory for a PID
View calc_memory.sh
#!/bin/bash
if [ "$1" = "" ]
then
echo "Pass in a PID"
exit 1
fi
SMAPS=/proc/$1/smaps
@rezan
rezan / code.c
Last active Mar 7, 2016
Code example
View code.c
# this is a comment
int i = 0;
foo();
i++;
@rezan
rezan / cedexis.vcl
Last active Jul 6, 2016
Cedexis test objects local in Varnish Cache
View cedexis.vcl
/*
* Cedexis test object location: L34, L39
*
* Requires vmod null:
* https://github.com/varnish/libvmod-null
*
*/
vcl 4.0;
@rezan
rezan / edgestash_json.vcl
Created Sep 22, 2016
Edgestash VCL generated JSON variables
View edgestash_json.vcl
vcl 4.0;
# Edgestash
# VCL generated JSON variables
#
# /edgestash/test/1 template contents:
# Hello {{name}} {{test}}!
backend default
{
@rezan
rezan / m00026.vcl.c
Created Nov 9, 2016
C code for m00026.vtc (scoped object support)
View m00026.vcl.c
/* ---===### 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 Dec 21, 2016
A generic Varnish Cache worldpress VCL template
View wordpress.vcl
# Worldpress Varnish Cache VCL template
# 12/21/2016
vcl 4.0;
backend wordpress {
.host = "0.0.0.0";
.port = "0";
}