Varnish Cache Plus

Utils

Description

vmod_utils is a VMOD for useful functions that don’t require their own VMOD.

Functions

dyn_probe

OBJECT dyn_probe([STRING url], [STRING request], [BOOL tcponly], [INT expected_response], [DURATION timeout], [DURATION interval], [INT initial], [INT window], [INT threshold])

  • Description

    Build an object that is able to output a probe. The argument list is the same as for the static VCL declaration of a probe, with the same restrictions.

    This allows to generate probes in vcl_init, notably using dynamic values. Dynamic probes are used by dynamic backends to provide the flexibility that these backends require.

  • Return Value

    An object with the .probe() method.

probe

PROBE .probe()

  • Return Value

    The probe specified during the creation of the object.

  • VCL example

    sub vcl_init {
        # get the probe URL from an env variable
        new dyn_probe = utils.dyn_probe(sdt.getenv("PROBE_URL"));
        
        # create a dynamic backend with above probe
        new goto_dir = goto.dns_director("foo.example.com", probe= dyn_probe.probe());
    }
    

newline

STRING newline()

  • Description

    Return a string consisting of a newline escape sequence, \n.

  • Return Value

    The newline escape sequence, \n.

time_format

STRING time_format(STRING format, BOOL local_time, [TIME time])

  • Description

    Format the time according to format. This is an interface for strftime.

  • Return Value

    The formated time as a string.

    • format

      The format that the time should be in. For more information about possible options see the man page for strftime.

    • local_time

      Should the time be in the local time zone or GMT. Defaults to GMT.

    • time

      An optional parameter of a time to format. Defaults to the current time.

fast_304

VOID fast_304()

  • Description

    Perform a fast 304 cache insert. New or changed headers will not be updated into cache. The object currently in cache will simply have its TTL extended. This reduces the cache read/write overhead of a 304 response to zero. Can only be used in vcl_backend_response. If used on a non 304 response, it is ignored.

  • Return Value

    None

vcl_name

STRING vcl_name()

  • Return Value

    The name of the current VCL.