Commit e0fe0e50 authored by Nils Goroll's avatar Nils Goroll

Improve return(<action>) documentation

We had two places where we documented common actions, and one of them
was outdated.
parent 239a8a0d
.. _user-guide-vcl_actions: .. _user-guide-vcl_actions:
actions Actions
~~~~~~~ =======
The most common actions to return are these: Actions are used with the ``return(<action>)`` keyword, which returns
control from subroutines back to varnish. The action determines how
processing in varnish continues as shown in :ref:`reference-states`.
.. XXX:Maybe a bit more explanation here what is an action and how it is returned? benc Common actions are documented here, while additional actions specific
to only one or some subroutines are documented in
:ref:`vcl-built-in-subs` as well as which action can be used from
which built in subroutine.
*pass* common actions for the client and backend side
When you return pass the request and subsequent response will be passed to ----------------------------------------------
and from the backend server. It won't be cached. `pass` can be returned from
`vcl_recv`.
*hash* .. _fail:
When you return hash from `vcl_recv` you tell Varnish to deliver content
from cache even if the request otherwise indicates that the request
should be passed.
*pipe* ``fail``
~~~~~~~~
.. XXX:What is pipe? benc Transition to :ref:`vcl_synth` on the client side as for
``return(synth(503, "VCL Failed"))``, but with any request state
changes undone as if ``std.rollback()`` was called and forcing a
connection close.
Pipe can be returned from `vcl_recv` as well. Pipe short circuits the Intended for fatal errors, for which only minimal error handling is
client and the backend connections and Varnish will just sit there possible.
and shuffle bytes back and forth. Varnish will not look at the data being
send back and forth - so your logs will be incomplete.
*deliver* common actions for the client side
Deliver the object to the client. Usually returned from `vcl_backend_response`. ----------------------------------
*restart* .. _synth:
Restart processing of the request. You can restart the processing of
the whole transaction. Changes to the `req` object are retained, except
for `req.backend_hint`, which gets reset to the default backend.
*retry* ``synth(status code, reason)``
Retry the request against the backend. This can be returned from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`vcl_backend_response` or `vcl_backend_error` if you don't like the response
that the backend delivered. Transition to :ref:`vcl_synth` with ``resp.status`` and
``resp.reason`` being preset to the arguments of ``synth()``.
.. _pass:
``pass``
~~~~~~~~
Switch to pass mode, making the current request not use the cache
and not putting its response into it. Control will eventually pass to
:ref:`vcl_pass`.
.. _pipe:
``pipe``
~~~~~~~~
Switch to pipe mode. Control will eventually pass to
:ref:`vcl_pipe`.
.. _restart:
``restart``
~~~~~~~~~~~
Restart the transaction. Increases the ``req.restarts`` counter.
If the number of restarts is higher than the *max_restarts*
parameter, control is passed to :ref:`vcl_synth` as for
``return(synth(503, "Too many restarts"))``
For a restart, all modifications to ``req`` attributes are
preserved except for ``req.restarts`` and ``req.xid``, which need
to change by design.
common actions for the backend side
-----------------------------------
.. _abandon:
``abandon``
~~~~~~~~~~~
Abandon the backend request. Unless the backend request was a
background fetch, control is passed to :ref:`vcl_synth` on the
client side with ``resp.status`` preset to 503.
...@@ -9,64 +9,21 @@ and backend requests as well as upon ``vcl.load`` and ``vcl.discard``. ...@@ -9,64 +9,21 @@ and backend requests as well as upon ``vcl.load`` and ``vcl.discard``.
See :ref:`reference-states` for a detailed graphical overview of the See :ref:`reference-states` for a detailed graphical overview of the
states and how they relate to core code functions and VCL subroutines. states and how they relate to core code functions and VCL subroutines.
Subroutines always terminate with a ``return()`` on a keyword, which Built-in subroutines always terminate with a ``return(<action>)``,
determines how processing continues in the request processing state where ``<action>`` determines how processing continues in the request
machine. processing state machine.
The behaviour for ``return()`` keywords is identical or at least The behaviour of actions is identical or at least similar across
similar across subroutines, so differences are only documented where subroutines, so differences are only documented where relevant.
relevant.
common return keywords for the client and backend side Common actions are documented in
------------------------------------------------------ :ref:`user-guide-vcl_actions`. Actions specific to only one or some
subroutines are documented herein.
.. _fail:
``fail``
Transition to :ref:`vcl_synth` on the client side as for
``return(synth(503, "VCL Failed"))``, but with any request state
changes undone as if ``std.rollback()`` was called and forcing a
connection close.
Intended for fatal errors, for which only minimal error handling is
possible.
client side client side
----------- -----------
common return keywords for the client side
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _synth:
``synth(status code, reason)``
Transition to :ref:`vcl_synth` with ``resp.status`` and
``resp.reason`` being preset to the arguments of ``synth()``.
.. _pass:
``pass``
Switch to pass mode. Control will eventually pass to
:ref:`vcl_pass`.
.. _pipe:
``pipe``
Switch to pipe mode. Control will eventually pass to
:ref:`vcl_pipe`.
.. _restart:
``restart``
Restart the transaction. Increases the ``req.restarts`` counter.
If the number of restarts is higher than the *max_restarts*
parameter, control is passed to :ref:`vcl_synth` as for
``return(synth(503, "Too many restarts"))``
For a restart, all modifications to ``req`` attributes are
preserved except for ``req.restarts`` and ``req.xid``, which need
to change by design.
.. _vcl_recv: .. _vcl_recv:
vcl_recv vcl_recv
...@@ -84,19 +41,19 @@ The `vcl_recv` subroutine may terminate with calling ``return()`` on one ...@@ -84,19 +41,19 @@ The `vcl_recv` subroutine may terminate with calling ``return()`` on one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``pass`` ``pass``
see `pass`_ see :ref:`pass`
``pipe`` ``pipe``
see `pipe`_ see :ref:`pipe`
``hash`` ``hash``
Continue processing the object as a potential candidate for Continue processing the object as a potential candidate for
...@@ -134,10 +91,10 @@ The `vcl_pipe` subroutine may terminate with calling ``return()`` with one ...@@ -134,10 +91,10 @@ The `vcl_pipe` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``pipe`` ``pipe``
Proceed with pipe mode. Proceed with pipe mode.
...@@ -156,13 +113,13 @@ The `vcl_pass` subroutine may terminate with calling ``return()`` with one ...@@ -156,13 +113,13 @@ The `vcl_pass` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``fetch`` ``fetch``
Proceed with pass mode - initiate a backend request. Proceed with pass mode - initiate a backend request.
...@@ -179,7 +136,7 @@ The `vcl_hash` subroutine may terminate with calling ``return()`` with one ...@@ -179,7 +136,7 @@ The `vcl_hash` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``lookup`` ``lookup``
Look up the object in cache. Look up the object in cache.
...@@ -210,13 +167,13 @@ The `vcl_purge` subroutine may terminate with calling ``return()`` with one ...@@ -210,13 +167,13 @@ The `vcl_purge` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
.. _vcl_miss: .. _vcl_miss:
...@@ -234,16 +191,16 @@ The `vcl_miss` subroutine may terminate with calling ``return()`` with one ...@@ -234,16 +191,16 @@ The `vcl_miss` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``pass`` ``pass``
see `pass`_ see :ref:`pass`
``fetch`` ``fetch``
Retrieve the requested object from the backend. Control will Retrieve the requested object from the backend. Control will
...@@ -262,16 +219,16 @@ The `vcl_hit` subroutine may terminate with calling ``return()`` ...@@ -262,16 +219,16 @@ The `vcl_hit` subroutine may terminate with calling ``return()``
with one of the following keywords: with one of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``pass`` ``pass``
see `pass`_ see :ref:`pass`
``deliver`` ``deliver``
Deliver the object. If it is stale, a background fetch to refresh Deliver the object. If it is stale, a background fetch to refresh
...@@ -288,13 +245,13 @@ The `vcl_deliver` subroutine may terminate with calling ``return()`` with one ...@@ -288,13 +245,13 @@ The `vcl_deliver` subroutine may terminate with calling ``return()`` with one
of the following keywords: of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``synth(status code, reason)`` ``synth(status code, reason)``
see `synth`_ see :ref:`synth`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``deliver`` ``deliver``
Deliver the object to the client. Deliver the object to the client.
...@@ -315,10 +272,10 @@ The subroutine may terminate with calling ``return()`` with one of the ...@@ -315,10 +272,10 @@ The subroutine may terminate with calling ``return()`` with one of the
following keywords: following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``restart`` ``restart``
see `restart`_ see :ref:`restart`
``deliver`` ``deliver``
Directly deliver the object defined by `vcl_synth` to the client Directly deliver the object defined by `vcl_synth` to the client
...@@ -327,17 +284,6 @@ following keywords: ...@@ -327,17 +284,6 @@ following keywords:
Backend Side Backend Side
------------ ------------
common return keywords for the backend side
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _abandon:
``abandon``
Abandon the backend request. Unless the backend request was a
background fetch, control is passed to :ref:`vcl_synth` on the
client side with ``resp.status`` preset to 503.
.. _vcl_backend_fetch: .. _vcl_backend_fetch:
vcl_backend_fetch vcl_backend_fetch
...@@ -350,10 +296,10 @@ The `vcl_backend_fetch` subroutine may terminate with calling ...@@ -350,10 +296,10 @@ The `vcl_backend_fetch` subroutine may terminate with calling
``return()`` with one of the following keywords: ``return()`` with one of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``abandon`` ``abandon``
see `abandon`_ see :ref:`abandon`
``fetch`` ``fetch``
Fetch the object from the backend. Fetch the object from the backend.
...@@ -403,10 +349,10 @@ The `vcl_backend_response` subroutine may terminate with calling ...@@ -403,10 +349,10 @@ The `vcl_backend_response` subroutine may terminate with calling
``return()`` with one of the following keywords: ``return()`` with one of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``abandon`` ``abandon``
see `abandon`_ see :ref:`abandon`
``deliver`` ``deliver``
For a 304 response, create an updated cache object. For a 304 response, create an updated cache object.
...@@ -507,7 +453,7 @@ vcl_backend_error ...@@ -507,7 +453,7 @@ vcl_backend_error
This subroutine is called if we fail the backend fetch or if This subroutine is called if we fail the backend fetch or if
*max_retries* has been exceeded. *max_retries* has been exceeded.
Returning with `abandon`_ does not leave a cache object. Returning with :ref:`abandon` does not leave a cache object.
If returning with ``deliver`` and a ``beresp.ttl > 0s``, a synthetic If returning with ``deliver`` and a ``beresp.ttl > 0s``, a synthetic
cache object is generated in VCL, whose body may be constructed using cache object is generated in VCL, whose body may be constructed using
...@@ -527,10 +473,10 @@ The `vcl_backend_error` subroutine may terminate with calling ``return()`` ...@@ -527,10 +473,10 @@ The `vcl_backend_error` subroutine may terminate with calling ``return()``
with one of the following keywords: with one of the following keywords:
``fail`` ``fail``
see `fail`_ see :ref:`fail`
``abandon`` ``abandon``
see `abandon`_ see :ref:`abandon`
``deliver`` ``deliver``
Deliver and possibly cache the object defined in Deliver and possibly cache the object defined in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment