trAvis - MANAGER
Edit File: vcl-built-in-subs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Built in subroutines — Varnish version 5.2.1 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '5.2.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="top" title="Varnish version 5.2.1 documentation" href="../index.html" /> <link rel="up" title="VCL - Varnish Configuration Language" href="vcl.html" /> <link rel="next" title="Request and response VCL objects" href="vcl-variables.html" /> <link rel="prev" title="VCL Syntax" href="vcl-syntax.html" /> </head> <body role="document"> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="vcl-variables.html" title="Request and response VCL objects" accesskey="N">next</a> |</li> <li class="right" > <a href="vcl-syntax.html" title="VCL Syntax" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 5.2.1 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Users Guide</a> »</li> <li class="nav-item nav-item-2"><a href="vcl.html" accesskey="U">VCL - Varnish Configuration Language</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="built-in-subroutines"> <span id="vcl-built-in-subs"></span><h1>Built in subroutines<a class="headerlink" href="#built-in-subroutines" title="Permalink to this headline">¶</a></h1> <p>Various built-in subroutines are called during processing of client- and backend requests as well as upon <code class="docutils literal"><span class="pre">vcl.load</span></code> and <code class="docutils literal"><span class="pre">vcl.discard</span></code>.</p> <p>See <a class="reference internal" href="../reference/states.html#reference-states"><span class="std std-ref">Varnish Processing States</span></a> for a defailed graphical overview of the states and how they relate to core code functions and VCL subroutines.</p> <div class="section" id="client-side"> <h2>client side<a class="headerlink" href="#client-side" title="Permalink to this headline">¶</a></h2> <div class="section" id="vcl-recv"> <span id="id1"></span><h3>vcl_recv<a class="headerlink" href="#vcl-recv" title="Permalink to this headline">¶</a></h3> <p>Called at the beginning of a request, after the complete request has been received and parsed, after a <cite>restart</cite> or as the result of an ESI include.</p> <p>Its purpose is to decide whether or not to serve the request, possibly modify it and decide on how to process it further. A backend hint may be set as a default for the backend processing side.</p> <p>The <cite>vcl_recv</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> on one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">hash</span></code></dt> <dd>Continue processing the object as a potential candidate for caching. Passes the control over to <a class="reference internal" href="#vcl-hash"><span class="std std-ref">vcl_hash</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">pass</span></code></dt> <dd>Switch to pass mode. Control will eventually pass to <a class="reference internal" href="#vcl-pass"><span class="std std-ref">vcl_pass</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">pipe</span></code></dt> <dd>Switch to pipe mode. Control will eventually pass to <a class="reference internal" href="#vcl-pipe"><span class="std std-ref">vcl_pipe</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> <dt><code class="docutils literal"><span class="pre">purge</span></code></dt> <dd>Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-pipe"> <span id="id2"></span><h3>vcl_pipe<a class="headerlink" href="#vcl-pipe" title="Permalink to this headline">¶</a></h3> <p>Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will ever get called after <cite>vcl_pipe</cite>.</p> <p>The <cite>vcl_pipe</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">pipe</span></code></dt> <dd>Proceed with pipe mode.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-pass"> <span id="id3"></span><h3>vcl_pass<a class="headerlink" href="#vcl-pass" title="Permalink to this headline">¶</a></h3> <p>Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client connection are handled normally.</p> <p>The <cite>vcl_pass</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">fetch</span></code></dt> <dd>Proceed with pass mode - initiate a backend request.</dd> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-hit"> <span id="id4"></span><h3>vcl_hit<a class="headerlink" href="#vcl-hit" title="Permalink to this headline">¶</a></h3> <p>Called when a cache lookup is successful. The object being hit may be stale: It can have a zero or negative <cite>ttl</cite> with only <cite>grace</cite> or <cite>keep</cite> time left.</p> <p>The <cite>vcl_hit</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">deliver</span></code></dt> <dd>Deliver the object. If it is stale, a background fetch to refresh it is triggered.</dd> <dt><code class="docutils literal"><span class="pre">miss</span></code></dt> <dd>Synchronously refresh the object from the backend despite the cache hit. Control will eventually pass to <a class="reference internal" href="#vcl-miss"><span class="std std-ref">vcl_miss</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">pass</span></code></dt> <dd>Switch to pass mode. Control will eventually pass to <a class="reference internal" href="#vcl-pass"><span class="std std-ref">vcl_pass</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> <dt><code class="docutils literal"><span class="pre">fetch</span></code> (deprecated)</dt> <dd>same as <code class="docutils literal"><span class="pre">miss</span></code>. Will get removed in a future version, triggers a VCL_Error log message.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-miss"> <span id="id5"></span><h3>vcl_miss<a class="headerlink" href="#vcl-miss" title="Permalink to this headline">¶</a></h3> <p>Called after a cache lookup if the requested document was not found in the cache or if <a class="reference internal" href="#vcl-hit"><span class="std std-ref">vcl_hit</span></a> returned <code class="docutils literal"><span class="pre">fetch</span></code>.</p> <p>Its purpose is to decide whether or not to attempt to retrieve the document from the backend. A backend hint may be set as a default for the backend processing side.</p> <p>The <cite>vcl_miss</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">fetch</span></code></dt> <dd>Retrieve the requested object from the backend. Control will eventually pass to <cite>vcl_backend_fetch</cite>.</dd> <dt><code class="docutils literal"><span class="pre">pass</span></code></dt> <dd>Switch to pass mode. Control will eventually pass to <a class="reference internal" href="#vcl-pass"><span class="std std-ref">vcl_pass</span></a>.</dd> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-hash"> <span id="id6"></span><h3>vcl_hash<a class="headerlink" href="#vcl-hash" title="Permalink to this headline">¶</a></h3> <p>Called after <cite>vcl_recv</cite> to create a hash value for the request. This is used as a key to look up the object in Varnish.</p> <p>The <cite>vcl_hash</cite> subroutine may only terminate with calling <code class="docutils literal"><span class="pre">return(lookup)</span></code>:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">lookup</span></code></dt> <dd><p class="first">Look up the object in cache. Control passes to <a class="reference internal" href="#vcl-purge"><span class="std std-ref">vcl_purge</span></a> when coming from a <code class="docutils literal"><span class="pre">purge</span></code> return in <cite>vcl_recv</cite>. Otherwise control passes to the next subroutine depending on the result of the cache lookup:</p> <ul class="last simple"> <li>a hit: pass to <a class="reference internal" href="#vcl-hit"><span class="std std-ref">vcl_hit</span></a></li> <li>a miss or a hit on a hit-for-miss object (an object with <code class="docutils literal"><span class="pre">obj.uncacheable</span> <span class="pre">==</span> <span class="pre">true</span></code>): pass to <a class="reference internal" href="#vcl-miss"><span class="std std-ref">vcl_miss</span></a></li> <li>a hit on a hit-for-pass object (for which <code class="docutils literal"><span class="pre">pass(DURATION)</span></code> had been previously returned from <code class="docutils literal"><span class="pre">vcl_backend_response</span></code>): pass to <a class="reference internal" href="#vcl-pass"><span class="std std-ref">vcl_pass</span></a></li> </ul> </dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-purge"> <span id="id7"></span><h3>vcl_purge<a class="headerlink" href="#vcl-purge" title="Permalink to this headline">¶</a></h3> <p>Called after the purge has been executed and all its variants have been evited.</p> <p>The <cite>vcl_purge</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-deliver"> <span id="id8"></span><h3>vcl_deliver<a class="headerlink" href="#vcl-deliver" title="Permalink to this headline">¶</a></h3> <p>Called before any object except a <cite>vcl_synth</cite> result is delivered to the client.</p> <p>The <cite>vcl_deliver</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">deliver</span></code></dt> <dd>Deliver the object to the client.</dd> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> <dt><code class="docutils literal"><span class="pre">synth(status</span> <span class="pre">code,</span> <span class="pre">reason)</span></code></dt> <dd>Transition to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> with <code class="docutils literal"><span class="pre">resp.status</span></code> and <code class="docutils literal"><span class="pre">resp.reason</span></code> being preset to the arguments of <code class="docutils literal"><span class="pre">synth()</span></code>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-synth"> <span id="id9"></span><h3>vcl_synth<a class="headerlink" href="#vcl-synth" title="Permalink to this headline">¶</a></h3> <p>Called to deliver a synthetic object. A synthetic object is generated in VCL, not fetched from the backend. Its body may be constructed using the <code class="docutils literal"><span class="pre">synthetic()</span></code> function.</p> <p>A <cite>vcl_synth</cite> defined object never enters the cache, contrary to a <a class="reference internal" href="#vcl-backend-error"><span class="std std-ref">vcl_backend_error</span></a> defined object, which may end up in cache.</p> <p>The subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">deliver</span></code></dt> <dd>Directly deliver the object defined by <cite>vcl_synth</cite> to the client without calling <cite>vcl_deliver</cite>.</dd> <dt><code class="docutils literal"><span class="pre">restart</span></code></dt> <dd>Restart the transaction. Increases the restart counter. If the number of restarts is higher than <em>max_restarts</em> Varnish emits a guru meditation error.</dd> </dl> </div></blockquote> </div> </div> <div class="section" id="backend-side"> <h2>Backend Side<a class="headerlink" href="#backend-side" title="Permalink to this headline">¶</a></h2> <div class="section" id="vcl-backend-fetch"> <span id="id10"></span><h3>vcl_backend_fetch<a class="headerlink" href="#vcl-backend-fetch" title="Permalink to this headline">¶</a></h3> <p>Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.</p> <p>The <cite>vcl_backend_fetch</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">fetch</span></code></dt> <dd>Fetch the object from the backend.</dd> <dt><code class="docutils literal"><span class="pre">abandon</span></code></dt> <dd>Abandon the backend request. Unless the backend request was a background fetch, control is passed to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> on the client side with <code class="docutils literal"><span class="pre">resp.status</span></code> preset to 503.</dd> </dl> </div></blockquote> <p>Before calling <cite>vcl_backend_fetch</cite>, varnish core prepares the <cite>bereq</cite> backend request as follows:</p> <ul class="simple"> <li>Unless the request is a <cite>pass</cite>,<ul> <li>set <code class="docutils literal"><span class="pre">bereq.method</span></code> to <code class="docutils literal"><span class="pre">GET</span></code> and <code class="docutils literal"><span class="pre">bereq.proto</span></code> to <code class="docutils literal"><span class="pre">HTTP/1.1</span></code> and</li> <li>set <code class="docutils literal"><span class="pre">bereq.http.Accept_Encoding</span></code> to <code class="docutils literal"><span class="pre">gzip</span></code> if <a class="reference internal" href="../reference/varnishd.html#ref-param-http-gzip-support"><span class="std std-ref">http_gzip_support</span></a> is enabled.</li> </ul> </li> <li>If there is an existing cache object to be revalidated, set <code class="docutils literal"><span class="pre">bereq.http.If-Modified-Since</span></code> from its <code class="docutils literal"><span class="pre">Last-Modified</span></code> header and/or set <code class="docutils literal"><span class="pre">bereq.http.If-None-Match</span></code> from its <code class="docutils literal"><span class="pre">Etag</span></code> header</li> <li>Set <code class="docutils literal"><span class="pre">bereq.http.X-Varnish</span></code> to the current transaction id (<cite>vxid</cite>)</li> </ul> <p>These changes can be undone or modified in <cite>vcl_backend_fetch</cite> before the backend request is issued.</p> <p>In particular, to cache non-GET requests, <code class="docutils literal"><span class="pre">req.method</span></code> needs to be saved to a header or variable in <a class="reference internal" href="#vcl-recv"><span class="std std-ref">vcl_recv</span></a> and restored to <code class="docutils literal"><span class="pre">bereq.method</span></code>. Notice that caching non-GET requests typically also requires changing the cache key in <a class="reference internal" href="#vcl-hash"><span class="std std-ref">vcl_hash</span></a> e.g. by also hashing the request method and/or request body.</p> <p>HEAD request can be satisfied from cached GET responses.</p> </div> <div class="section" id="vcl-backend-response"> <span id="id11"></span><h3>vcl_backend_response<a class="headerlink" href="#vcl-backend-response" title="Permalink to this headline">¶</a></h3> <p>Called after the response headers have been successfully retrieved from the backend.</p> <p>For a 304 response, varnish core code amends <code class="docutils literal"><span class="pre">beresp</span></code> before calling <cite>vcl_backend_response</cite>:</p> <ul class="simple"> <li>If the gzip status changed, <code class="docutils literal"><span class="pre">Content-Encoding</span></code> is unset and any <code class="docutils literal"><span class="pre">Etag</span></code> is weakened</li> <li>Any headers not present in the 304 response are copied from the existing cache object. <code class="docutils literal"><span class="pre">Content-Length</span></code> is copied if present in the existing cache object and discarded otherwise.</li> <li>The status gets set to 200.</li> </ul> <p><cite>beresp.was_304</cite> marks that this conditional response processing has happened.</p> <p>Note: Backend conditional requests are independend of client conditional requests, so clients may receive 304 responses no matter if a backend request was conditional.</p> <p>The <cite>vcl_backend_response</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">deliver</span></code></dt> <dd>For a 304 response, create an updated cache object. Otherwise, fetch the object body from the backend and initiate delivery to any waiting client requests, possibly in parallel (streaming).</dd> <dt><code class="docutils literal"><span class="pre">pass(duration)</span></code></dt> <dd>Mark the object as a hit-for-pass for the given duration. Subsequent lookups hitting this object will be turned into passed transactions, as if <code class="docutils literal"><span class="pre">vcl_recv</span></code> had returned <code class="docutils literal"><span class="pre">pass</span></code>.</dd> <dt><code class="docutils literal"><span class="pre">abandon</span></code></dt> <dd>Abandon the backend request. Unless the backend request was a background fetch, control is passed to <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> on the client side with <code class="docutils literal"><span class="pre">resp.status</span></code> preset to 503.</dd> <dt><code class="docutils literal"><span class="pre">retry</span></code></dt> <dd>Retry the backend transaction. Increases the <cite>retries</cite> counter. If the number of retries is higher than <em>max_retries</em>, control will be passed to <a class="reference internal" href="#vcl-backend-error"><span class="std std-ref">vcl_backend_error</span></a>.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-backend-error"> <span id="id12"></span><h3>vcl_backend_error<a class="headerlink" href="#vcl-backend-error" title="Permalink to this headline">¶</a></h3> <p>This subroutine is called if we fail the backend fetch or if <em>max_retries</em> has been exceeded.</p> <p>A synthetic object is generated in VCL, whose body may be constructed using the <code class="docutils literal"><span class="pre">synthetic()</span></code> function.</p> <p>The <cite>vcl_backend_error</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">deliver</span></code></dt> <dd>Deliver and possibly cache the object defined in <cite>vcl_backend_error</cite> <strong>as if it was fetched from the backend</strong>, also referred to as a "backend synth".</dd> <dt><code class="docutils literal"><span class="pre">retry</span></code></dt> <dd>Retry the backend transaction. Increases the <cite>retries</cite> counter. If the number of retries is higher than <em>max_retries</em>, <a class="reference internal" href="#vcl-synth"><span class="std std-ref">vcl_synth</span></a> on the client side is called with <code class="docutils literal"><span class="pre">resp.status</span></code> preset to 503.</dd> </dl> </div></blockquote> </div> </div> <div class="section" id="vcl-load-vcl-discard"> <h2>vcl.load / vcl.discard<a class="headerlink" href="#vcl-load-vcl-discard" title="Permalink to this headline">¶</a></h2> <div class="section" id="vcl-init"> <span id="id13"></span><h3>vcl_init<a class="headerlink" href="#vcl-init" title="Permalink to this headline">¶</a></h3> <p>Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.</p> <p>The <cite>vcl_init</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">ok</span></code></dt> <dd>Normal return, VCL continues loading.</dd> <dt><code class="docutils literal"><span class="pre">fail</span></code></dt> <dd>Abort loading of this VCL.</dd> </dl> </div></blockquote> </div> <div class="section" id="vcl-fini"> <span id="id14"></span><h3>vcl_fini<a class="headerlink" href="#vcl-fini" title="Permalink to this headline">¶</a></h3> <p>Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.</p> <p>The <cite>vcl_fini</cite> subroutine may terminate with calling <code class="docutils literal"><span class="pre">return()</span></code> with one of the following keywords:</p> <blockquote> <div><dl class="docutils"> <dt><code class="docutils literal"><span class="pre">ok</span></code></dt> <dd>Normal return, VCL will be discarded.</dd> </dl> </div></blockquote> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Built in subroutines</a><ul> <li><a class="reference internal" href="#client-side">client side</a><ul> <li><a class="reference internal" href="#vcl-recv">vcl_recv</a></li> <li><a class="reference internal" href="#vcl-pipe">vcl_pipe</a></li> <li><a class="reference internal" href="#vcl-pass">vcl_pass</a></li> <li><a class="reference internal" href="#vcl-hit">vcl_hit</a></li> <li><a class="reference internal" href="#vcl-miss">vcl_miss</a></li> <li><a class="reference internal" href="#vcl-hash">vcl_hash</a></li> <li><a class="reference internal" href="#vcl-purge">vcl_purge</a></li> <li><a class="reference internal" href="#vcl-deliver">vcl_deliver</a></li> <li><a class="reference internal" href="#vcl-synth">vcl_synth</a></li> </ul> </li> <li><a class="reference internal" href="#backend-side">Backend Side</a><ul> <li><a class="reference internal" href="#vcl-backend-fetch">vcl_backend_fetch</a></li> <li><a class="reference internal" href="#vcl-backend-response">vcl_backend_response</a></li> <li><a class="reference internal" href="#vcl-backend-error">vcl_backend_error</a></li> </ul> </li> <li><a class="reference internal" href="#vcl-load-vcl-discard">vcl.load / vcl.discard</a><ul> <li><a class="reference internal" href="#vcl-init">vcl_init</a></li> <li><a class="reference internal" href="#vcl-fini">vcl_fini</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="vcl-syntax.html" title="previous chapter">VCL Syntax</a></p> <h4>Next topic</h4> <p class="topless"><a href="vcl-variables.html" title="next chapter">Request and response VCL objects</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/users-guide/vcl-built-in-subs.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <div><input type="text" name="q" /></div> <div><input type="submit" value="Go" /></div> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="vcl-variables.html" title="Request and response VCL objects" >next</a> |</li> <li class="right" > <a href="vcl-syntax.html" title="VCL Syntax" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 5.2.1 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Users Guide</a> »</li> <li class="nav-item nav-item-2"><a href="vcl.html" >VCL - Varnish Configuration Language</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2010-2014, Varnish Software AS. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. </div> </body> </html>