Skip to content

Instantly share code, notes, and snippets.

@matthewjackowski
Last active April 5, 2016 14:46
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 matthewjackowski/aea52882219d697f67bbddac87bab3c1 to your computer and use it in GitHub Desktop.
Save matthewjackowski/aea52882219d697f67bbddac87bab3c1 to your computer and use it in GitHub Desktop.
A basic vcl for the app
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "wordpress";
.port = "80";
}
acl edgecache {
"172.31.12.197";
"52.26.20.120";
"127.0.0.1";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
set req.backend_hint = default;
if ((req.url ~ "(wp-login|wp-admin)" || req.url ~ "preview=true") || !(client.ip ~ edgecache)) {
# pass if url is an admin url
if (req.url ~ "(wp-login|wp-admin)" || req.url ~ "preview=true" || req.url ~ "xmlrpc.php") {
return (pass);
} else {
return(synth(403, "Not allowed"));
}
}
# pass if wp-admin cookies
if (req.http.cookie) {
if (req.http.cookie ~ "(wordpress_|wp-settings-)") {
return(pass);
} else {
unset req.http.cookie;
}
}
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
# Don't store backend
if (bereq.url ~ "wp-(login|admin)" || bereq.url ~ "preview=true") {
set beresp.uncacheable = true;
set beresp.ttl = 30s;
return (deliver);
}
unset beresp.http.Cache-Control;
unset beresp.http.set-cookie;
unset beresp.http.cookie;
set beresp.ttl = 24h;
set beresp.grace = 1w;
}
sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the response to the client.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment