1VMOD(PURGE)                                                        VMOD(PURGE)
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
77       untouched.  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

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