The Varnish standard module contains useful, generic function that
don't quite fit in the VCL core, but are still considered very useful to a
broad audience.
- Prototype
- set_ip_tos(INT i)
- Return
value
- Void
- Description
- Sets the Type-of-Service flag for the current session. Please note that
the TOS flag is not removed by the end of the request so probably want to
set it on every request should you utilize it.
- Example
-
if (req.url ~ ^/slow/) {
std.set_ip_tos(0x0);
}
- Prototype
- fileread(STRING filename)
- Return
value
- String
- Description
- Reads a file and returns a string with the content. Please note that it is
not recommended to send variables to this function the caching in the
function doesn't take this into account. Also, files are not re-read.
- Example
- set beresp.http.x-served-by =
std.fileread("/etc/hostname");
- Prototype
- duration(STRING s, DURATION fallback)
- Return
value
- Duration
- Description
- Converts the string s to seconds. s can be quantified with
the usual s (seconds), m (minutes), h (hours), d (days) and w (weeks)
units. If s fails to parse, fallback will be used.
- Example
- set beresp.ttl = std.duration("1w", 3600s);
- Prototype
- integer(STRING s, INT fallback)
- Return
value
- Int
- Description
- Converts the string s to an integer. If s fails to parse,
fallback will be used
- Example
- if (std.integer(beresp.http.x-foo, 0) > 5) { ... }
- Prototype
- collect(HEADER header)
- Return
value
- Void
- Description
- Collapses the header, joining the headers into one.
- Example
- std.collect(req.http.cookie); This will collapse several Cookie: headers
into one, long cookie header.
The Varnish standard module was released along with Varnish Cache
3.0. This manual page was written by Per Buer with help from Martin Blix
Grydeland.
This document is licensed under the same licence as Varnish
itself. See LICENCE for details.
- Copyright (c) 2011 Varnish Software