Skip to content

Instantly share code, notes, and snippets.

@samnazarko
Forked from lkarsten/default.vcl
Created October 11, 2015 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samnazarko/a20fe48f93af1f9a53c2 to your computer and use it in GitHub Desktop.
Save samnazarko/a20fe48f93af1f9a53c2 to your computer and use it in GitHub Desktop.
varnish vcl for ghost blogging platform
#
# Varnish VCL file for Ghost blogging platform.
# http://ghost.org/
#
# Written for Ghost v0.3.0.
#
# This is a low-hanging-fruit type of VCL. TTL of objects are overridden to 2
# minutes, and everything below /ghost/ is pass()-ed so the user sessions
# work.
#
# Author: Lasse Karstensen <lasse.karstensen@gmail.com>, September 2013.
backend default {
.host = "localhost";
# .port = "2368";
.port = "8081";
}
sub vcl_recv {
# If the client uses shift-F5, get (and cache) a fresh copy. Nice for
# systems without content invalidation. Big sites will want to disable
# this.
if (req.http.cache-control ~ "no-cache") {
set req.hash_always_miss = true;
}
set req.http.x-pass = "false";
# TODO: I haven't seen any urls for logging access. When the
# analytics parts of ghost are done, this needs to be added in the
# exception list below.
if (req.url ~ "^/(api|signout)") {
set req.http.x-pass = "true";
} elseif (req.url ~ "^/ghost" && (req.url !~ "^/ghost/(img|css|fonts)")) {
set req.http.x-pass = "true";
}
if (req.http.x-pass == "true") {
return(pass);
}
unset req.http.cookie;
}
sub vcl_fetch {
# Only modify cookies/ttl outside of the management interface.
if (req.http.x-pass != "true") {
unset beresp.http.set-cookie;
if (beresp.status < 500 && beresp.ttl == 0s) {
set beresp.ttl = 2m;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment