1VMOD_PURGE(3)                                                    VMOD_PURGE(3)
2
3
4

NAME

6       vmod_purge - Varnish Purge Module
7

SYNOPSIS

9          import purge [as name] [from "path"]
10
11          INT hard()
12
13          INT soft(DURATION ttl, DURATION grace, DURATION keep)
14

DESCRIPTION

16       vmod_purge  contains  functions that offer a finer-grained control than
17       return(purge) from vcl_recv{}. The functions can only  be  called  from
18       vcl_hit{}  or  vcl_miss{} and they should in general be used in both to
19       ensure that all variants of a same object are taken care of.
20

EXAMPLE

22          sub vcl_recv {
23              if (req.method == "PURGE") {
24                  if (client.ip !~ purge_acl) {
25                      return (synth(405));
26                  }
27                  return (hash);
28              }
29          }
30
31          sub my_purge {
32              set req.http.purged = purge.hard();
33              if (req.http.purged == "0") {
34                  return (synth(404));
35              }
36              else {
37                  return (synth(200));
38              }
39          }
40
41          sub vcl_hit {
42              if (req.method == "PURGE") {
43                  call my_purge;
44              }
45          }
46
47          sub vcl_miss {
48              if (req.method == "PURGE") {
49                  call my_purge;
50              }
51          }
52
53          sub vcl_synth {
54              if (req.method == "PURGE") {
55                  if (req.http.purged) {
56                      set resp.http.purged = req.http.purged;
57                  }
58                  return (deliver);
59              }
60          }
61
62   INT hard()
63       This  is  equivalent  to  return(purge)  but  explicitly  called   from
64       vcl_hit{} and vcl_miss{}. It returns the number of purged objects.
65
66       Example:
67
68          set req.http.purged = purge.hard();
69
70   INT soft(DURATION ttl, DURATION grace, DURATION keep)
71          INT soft(DURATION ttl=0, DURATION grace=-1, DURATION keep=-1)
72
73       Sets the ttl, grace and keep.
74
75       By default, ttl is set to 0 with grace and keep periods left untouched.
76       Setting a negative value for grace or  keep  periods  leaves  them  un‐
77       touched.  Setting  all  three  parameters  to 0 is equivalent to a hard
78       purge. It can only be called from vcl_hit{} or vcl_miss{}.  It  returns
79       the number of soft-purged objects.
80

SEE ALSO

82vcl(7)
83
85          Copyright (c) 2017 Varnish Software AS
86          All rights reserved.
87
88          Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
89
90          SPDX-License-Identifier: BSD-2-Clause
91
92          Redistribution and use in source and binary forms, with or without
93          modification, are permitted provided that the following conditions
94          are met:
95          1. Redistributions of source code must retain the above copyright
96             notice, this list of conditions and the following disclaimer.
97          2. Redistributions in binary form must reproduce the above copyright
98             notice, this list of conditions and the following disclaimer in the
99             documentation and/or other materials provided with the distribution.
100
101          THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
102          ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
103          IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
104          ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
105          FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
106          DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
107          OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
108          HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
109          LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
110          OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
111          SUCH DAMAGE.
112
113
114
115
116                                                                 VMOD_PURGE(3)
Impressum