1
.. _tutorial-advanced_topics:
6
This tutorial has covered the basics in Varnish. If you read through
7
it all you should now have the skills to run Varnish.
9
Here is a short overview of topics that we haven't covered in the tutorial.
14
VCL is a bit more complex then what we've covered so far. There are a
15
few more subroutines available and there a few actions that we haven't
16
discussed. For a complete(ish) guide to VCL have a look at the VCL man
17
page - ref:`reference-vcl`.
19
Using In-line C to extend Varnish
20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
You can use *in-line C* to extend Varnish. Please note that you can
23
seriously mess up Varnish this way. The C code runs within the Varnish
24
Cache process so if your code generates a segfault the cache will crash.
26
One of the first uses I saw of In-line C was logging to syslog.::
28
# The include statements must be outside the subroutines.
35
syslog(LOG_INFO, "Something happened at VCL line XX.");
43
Varnish can cache create web pages by putting different pages
44
together. These *fragments* can have individual cache policies. If you
45
have a web site with a list showing the 5 most popular articles on
46
your site, this list can probably be cached as a fragment and included
47
in all the other pages. Used properly it can dramatically increase
48
your hit rate and reduce the load on your servers. ESI looks like this::
52
The time is: <esi:include src="/cgi-bin/date.cgi"/>
57
ESI is processed in vcl_fetch by setting *do_esi* to true.::
60
if (req.url == "/test.html") {
61
set beresp.do_esi = true; /* Do ESI processing */