--- /dev/null
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2008 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ * The default VCL code.
+ *
+ * NB! You do NOT need to copy & paste all of this into your won vcl code,
+ * if you do not handle one of the functions, the compiler will automaticall
+ * fall back to the default code.
+ *
+ * This code will be prefixed with a backend declaration built from the
+ * -b argument.
+ */
+
+sub vcl_recv {
+ if (req.request != "GET" &&
+ req.request != "HEAD" &&
+ req.request != "PUT" &&
+ req.request != "POST" &&
+ req.request != "TRACE" &&
+ req.request != "OPTIONS" &&
+ req.request != "DELETE") {
+ /* Non-RFC2616 or CONNECT which is weird. */
+ pipe;
+ }
+ if (req.http.Expect) {
+ /* Expect is just too hard at present. */
+ pipe;
+ }
+ if (req.request != "GET" && req.request != "HEAD") {
+ /* We only deal with GET and HEAD by default */
+ pass;
+ }
+ if (req.http.Authorization || req.http.Cookie) {
+ /* Not cacheable by default */
+ pass;
+ }
+ lookup;
+}
+
+sub vcl_pipe {
+ pipe;
+}
+
+sub vcl_pass {
+ pass;
+}
+
+sub vcl_hash {
+ set req.hash += req.url;
+ if (req.http.host) {
+ set req.hash += req.http.host;
+ } else {
+ set req.hash += server.ip;
+ }
+ hash;
+}
+
+sub vcl_hit {
+ if (!obj.cacheable) {
+ pass;
+ }
+ deliver;
+}
+
+sub vcl_miss {
+ fetch;
+}
+
+sub vcl_fetch {
+ if (!obj.cacheable) {
+ pass;
+ }
+ if (obj.http.Set-Cookie) {
+ pass;
+ }
+ set obj.prefetch = -30s;
+ deliver;
+}
+
+sub vcl_deliver {
+ deliver;
+}
+
+sub vcl_discard {
+ discard;
+}
+
+sub vcl_prefetch {
+ fetch;
+}
+
+sub vcl_timeout {
+ discard;
+}
+
+sub vcl_error {
+ set obj.http.Content-Type = "text/html; charset=utf-8";
+ synthetic {"
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+ <head>
+ <title>"} obj.status " " obj.response {"</title>
+ </head>
+ <body>
+ <h1>Error "} obj.status " " obj.response {"</h1>
+ <p>"} obj.response {"</p>
+ <h3>Guru Meditation:</h3>
+ <p>XID: "} req.xid {"</p>
+ <address><a href="http://www.varnish-cache.org/">Varnish</a></address>
+ </body>
+</html>
+"};
+ deliver;
+}
* Keep this in synch with man/vcl.7 and etc/default.vcl!
*/
static const char *default_vcl =
- "sub vcl_recv {\n"
- " if (req.request != \"GET\" &&\n"
- " req.request != \"HEAD\" &&\n"
- " req.request != \"PUT\" &&\n"
- " req.request != \"POST\" &&\n"
- " req.request != \"TRACE\" &&\n"
- " req.request != \"OPTIONS\" &&\n"
- " req.request != \"DELETE\") {\n"
- " /* Non-RFC2616 or CONNECT which is weird. */\n"
- " pipe;\n"
- " }\n"
- " if (req.http.Expect) {\n"
- " /* Expect is just too hard at present. */\n"
- " pipe;\n"
- " }\n"
- " if (req.request != \"GET\" && req.request != \"HEAD\") {\n"
- " /* We only deal with GET and HEAD by default */\n"
- " pass;\n"
- " }\n"
- " if (req.http.Authorization || req.http.Cookie) {\n"
- " /* Not cacheable by default */\n"
- " pass;\n"
- " }\n"
- " lookup;\n"
- "}\n"
- "\n"
- "sub vcl_pipe {\n"
- " pipe;\n"
- "}\n"
- "\n"
- "sub vcl_pass {\n"
- " pass;\n"
- "}\n"
- "\n"
- "sub vcl_hash {\n"
- " set req.hash += req.url;\n"
- " if (req.http.host) {\n"
- " set req.hash += req.http.host;\n"
- " } else {\n"
- " set req.hash += server.ip;\n"
- " }\n"
- " hash;\n"
- "}\n"
- "\n"
- "sub vcl_hit {\n"
- " if (!obj.cacheable) {\n"
- " pass;\n"
- " }\n"
- " deliver;\n"
- "}\n"
- "\n"
- "sub vcl_miss {\n"
- " fetch;\n"
- "}\n"
- "\n"
- "sub vcl_fetch {\n"
- " if (!obj.cacheable) {\n"
- " pass;\n"
- " }\n"
- " if (obj.http.Set-Cookie) {\n"
- " pass;\n"
- " }\n"
- " set obj.prefetch = -30s;"
- " deliver;\n"
- "}\n"
- "sub vcl_deliver {\n"
- " deliver;\n"
- "}\n"
- "sub vcl_discard {\n"
- " discard;\n"
- "}\n"
- "sub vcl_prefetch {\n"
- " fetch;\n"
- "}\n"
- "sub vcl_timeout {\n"
- " discard;\n"
- "}\n"
- "sub vcl_error {\n"
- " set obj.http.Content-Type = \"text/html; charset=utf-8\";"
- " synthetic {\"\n"
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
- "<html>\n"
- " <head>\n"
- " <title>\"} obj.status \" \" obj.response {\"</title>\n"
- " </head>\n"
- " <body>\n"
- " <h1>Error \"} obj.status \" \" obj.response {\"</h1>\n"
- " <p>\"} obj.response {\"</p>\n"
- " <h3>Guru Meditation:</h3>\n"
- " <p>XID: \"} req.xid {\"</p>\n"
- " <address><a href=\"http://www.varnish-cache.org/\">Varnish</a></address>\n"
- " </body>\n"
- "</html>\n"
- "\"};\n"
- " deliver;\n"
- "}\n"
+#include "default_vcl.h"
"" ;
/*