Skip to content

Commit

Permalink
synth improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Velázquez committed Mar 15, 2016
1 parent aa33118 commit 4d487b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
34 changes: 19 additions & 15 deletions .aspell.en.pws
@@ -1,4 +1,4 @@
personal_ws-1.1 en 448
personal_ws-1.1 en 451
ajax
apache
google
Expand All @@ -7,6 +7,7 @@ netstat
multi
Magnus
ReqMethod
httpd
CDN
undef
API
Expand All @@ -16,8 +17,8 @@ CET
github
delim
arg
https
HTTP's
https
VMODs
Naghibi
nosni
Expand Down Expand Up @@ -52,8 +53,8 @@ RespProtocol
CType
SHared
Henning
CSS
DNS
CSS
csv
compressions
gcc
Expand Down Expand Up @@ -96,13 +97,14 @@ subrequests
HMAC
strcmp
README
httpie
HTTPie
httpie
varnishtop
urlencoded
regex
VaRY
HLS
functionalities
instantiation
IETF
maxage
Expand All @@ -116,6 +118,7 @@ objectcore
Makefile
nlpt
param
apachectl
Blix
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
IRC
Expand All @@ -127,8 +130,8 @@ cliok
sudo
txreq
RESTful
IPv
ipv
IPv
Argv
uint
Acceptor
Expand All @@ -144,8 +147,8 @@ clierr
LFU
metadata
saintmode
FreeBSD
freebsd
FreeBSD
gunzip
linux
Economization
Expand All @@ -157,12 +160,12 @@ Aondio
enmod
mgt
releasever
respstatus
RespStatus
respstatus
vmodtool
getNonMasqueraded
HashTwo
hashtwo
HashTwo
tIncluded
DDoS
workspace
Expand All @@ -176,8 +179,8 @@ SimpleHTTPServer
Kamp
codename
LRU
ReqURL
ReqUrl
ReqURL
asts
SELinux
LTS
Expand Down Expand Up @@ -261,19 +264,19 @@ helloworldtest
varnishapi
ubuntu
Footbar
rst
VBE
rst
VCA
src
vcc
src
recv
subrequest
util
SQL
VDD
VBP
vcl
VAV
vcl
VXIDs
TLS
setsebool
Expand All @@ -297,8 +300,8 @@ requesters
Rub�n
Webdev
systemctl
VIN
JPEG
VIN
ttl
rxreq
rxres
Expand All @@ -311,8 +314,8 @@ url
testbed
hdrbytes
Arianna
VLU
utf
VLU
BereqURL
malloc
dotMobi's
Expand Down Expand Up @@ -424,6 +427,7 @@ xb
VM
Hagander
ETags
CentOS
ws
TOUPDATE
Fialka
Expand All @@ -433,8 +437,8 @@ localhost
vstatdprobe
Karstensen
varnishlog
ETag
Etag
ETag
substring
noverify
AUTOEXTEND
Expand Down
21 changes: 12 additions & 9 deletions varnish_book.rst
Expand Up @@ -4447,9 +4447,11 @@ VCL – ``vcl_deliver``
VCL – ``vcl_synth``
-------------------

- Used to generate content from within Varnish, without talking to the backend
- Error messages go here by default
- Other use cases: Redirecting users (301/302 redirects)
- Used to generate content within Varnish
- Error messages can be created here
- Other use cases: redirecting users (301/302 redirects)

**vcl/default-vcl_synth.vcl**:

.. include:: vcl/default-vcl_synth.vcl
:literal:
Expand All @@ -4458,22 +4460,23 @@ VCL – ``vcl_synth``
.. container:: handout

To make a distinction between VCL synthetic responses and internally generated errors (when trying to fetch an object), there are two subroutines that handle errors in Varnish.
One is ``vcl_synth``, and the other is ``vcl_backend_error``.
To return control to ``vcl_synth``,call the ``synth()`` function like this::
You can create synthetic responses, e.g., personalized error messages, in ``vcl_synth``.
To call this subroutine you do::

return (synth(status_code, "reason"));

Note that the syntax ``synth`` is not a keyword, but a function with arguments.
Note that ``synth`` is not a keyword, but a function with arguments.

You must explicitly return the ``status code`` and ``reason`` arguments for ``vcl_synth``.
Setting headers on synthetic response bodies are done on ``resp.http``.

.. note::
Note how you can use ``{"`` and ``"}`` to make multi-line strings.
This is not limited to the ``synthetic()`` function, but can be used anywhere.

From ``vcl/default-vcl_synth.vcl``, note that ``{"`` and ``"}`` can be used to make multi-line strings.
This is not limited to the ``synthetic()`` function, but one can be used anywhere.

.. note::

A ``vcl_synth`` defined object is never stored in cache, contrary to a ``vcl_backend_error`` defined object, which may end up in cache.
``vcl_synth`` and ``vcl_backend_error`` replace ``vcl_error`` from Varnish 3.

Expand Down

0 comments on commit 4d487b2

Please sign in to comment.