r4435 - trunk/varnish-cache/man

ssm at projects.linpro.no ssm at projects.linpro.no
Fri Jan 8 10:13:17 CET 2010


Author: ssm
Date: 2010-01-08 10:13:17 +0100 (Fri, 08 Jan 2010)
New Revision: 4435

Modified:
   trunk/varnish-cache/man/vcl.7so
Log:
Document multiple subroutine definitions a bit more

Modified: trunk/varnish-cache/man/vcl.7so
===================================================================
--- trunk/varnish-cache/man/vcl.7so	2010-01-07 11:29:56 UTC (rev 4434)
+++ trunk/varnish-cache/man/vcl.7so	2010-01-08 09:13:17 UTC (rev 4435)
@@ -282,9 +282,6 @@
 .Pp
 Subroutines in VCL do not take arguments, nor do they return values.
 .Pp
-If multiple subroutines with the same name are defined, they are
-concatenated in the order in which the appear in the source.
-.Pp
 To call a subroutine, use the
 .Cm call
 keyword followed by the subroutine's name:
@@ -467,6 +464,36 @@
 See the
 .Sx EXAMPLES
 section for a listing of the default code.
+.Ss Multiple subroutines
+If multiple subroutines with the same name are defined, they are
+concatenated in the order in which the appear in the source.
+.Pp
+Example:
+.Bd -literal -offset 4n
+# in file "main.vcl"
+include "backends.vcl";
+include "purge.vcl";
+
+# in file "backends.vcl"
+sub vcl_recv {
+  if (req.http.host ~ "example.com") {
+    set req.backend = foo;
+  } elsif (req.http.host ~ "example.org") {
+    set req.backend = bar;
+  }
+}
+
+# in file "purge.vcl"
+sub vcl_recv {
+  if (client.ip ~ admin_network) {
+    if (req.http.Cache-Control ~ "no-cache") {
+      purge_url(req.url);
+    }
+  }
+}
+.Ed
+.Pp
+The builtin default subroutines are implicitly appended in this way.
 .Ss Variables
 Although subroutines take no arguments, the necessary information is
 made available to the handler subroutines through global variables.



More information about the varnish-commit mailing list