From aa53fbf63ddee1f2d9a353c2f64a79e108e1f101 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan@faked.org>
Date: Wed, 19 Mar 2014 22:51:30 +0100
Subject: [PATCH] add example Varnish VCL

---
 examples/varnish.vcl | 38 ++++++++++++++++++++++++++++++++++++++
 index.php            |  1 -
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 examples/varnish.vcl

diff --git a/examples/varnish.vcl b/examples/varnish.vcl
new file mode 100644
index 0000000..666cff3
--- /dev/null
+++ b/examples/varnish.vcl
@@ -0,0 +1,38 @@
+backend default {
+    .host = "127.0.0.1";
+    .port = "81";
+}
+
+sub vcl_recv {
+
+  if (req.http.host ~ "cdn[0-9]\.example.com" &&
+    req.url ~ "\.(gif|jpg|jpeg|png)(\?.*|)$") {
+        unset req.http.Cache-Control;
+        unset req.http.Cookie;
+        unset req.http.Accept-Encoding;
+        unset req.http.Vary;
+        return(lookup);
+  }
+
+}
+
+sub vcl_fetch {
+
+  if (req.http.host ~ "cdn[0-9]\.example.com" &&
+    req.url ~ "\.(gif|jpg|jpeg|png)(\?.*|)$") {
+        unset beresp.http.set-cookie;
+        set beresp.ttl = 1w;
+  }
+
+}
+
+sub vcl_deliver {
+
+  if (obj.hits > 0) {
+        set resp.http.X-Cache = "HIT";
+  } else {
+        set resp.http.X-Cache = "MISS";
+  }
+  return(deliver);
+
+}
diff --git a/index.php b/index.php
index c46329b..f9bef56 100644
--- a/index.php
+++ b/index.php
@@ -652,7 +652,6 @@ $origin_domain = strtolower( $exploded[1] );
 $origin_domain_exception = array_key_exists( $origin_domain, $origin_domain_exceptions ) ? $origin_domain_exceptions[$origin_domain] : 0;
 
 $scheme = 'http' . ( array_key_exists( 'ssl', $_GET ) ? 's' : '' ) . '://';
-
 parse_str( ( empty( $parsed['query'] ) ? '' : $parsed['query'] ),  $_GET  );
 
 $ext = strtolower( pathinfo( $parsed['path'], PATHINFO_EXTENSION ) );
-- 
GitLab