~ubuntu-branches/debian/sid/varnish/sid

« back to all changes in this revision

Viewing changes to doc/sphinx/=build/html/_sources/tutorial/advanced_topics.txt

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-29 15:23:24 UTC
  • mfrom: (0.1.15)
  • Revision ID: package-import@ubuntu.com-20111029152324-tdtlsurrv22ysknj
Tags: 3.0.2-1
* New upstream release
* Build from upstream tarball instead of git tag
* debian/watch: more specific regular expression

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _tutorial-advanced_topics:
 
2
 
 
3
Advanced topics
 
4
---------------
 
5
 
 
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.
 
8
 
 
9
Here is a short overview of topics that we haven't covered in the tutorial. 
 
10
 
 
11
More VCL
 
12
~~~~~~~~
 
13
 
 
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`.
 
18
 
 
19
Using In-line C to extend Varnish
 
20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
21
 
 
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.
 
25
 
 
26
One of the first uses I saw of In-line C was logging to syslog.::
 
27
 
 
28
        # The include statements must be outside the subroutines.
 
29
        C{
 
30
                #include <syslog.h>
 
31
        }C
 
32
        
 
33
        sub vcl_something {
 
34
                C{
 
35
                        syslog(LOG_INFO, "Something happened at VCL line XX.");
 
36
                }C
 
37
        }
 
38
 
 
39
 
 
40
Edge Side Includes
 
41
~~~~~~~~~~~~~~~~~~
 
42
 
 
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::
 
49
 
 
50
  <HTML>
 
51
  <BODY>
 
52
  The time is: <esi:include src="/cgi-bin/date.cgi"/>
 
53
  at this very moment.
 
54
  </BODY>
 
55
  </HTML>
 
56
 
 
57
ESI is processed in vcl_fetch by setting *do_esi* to true.::
 
58
 
 
59
  sub vcl_fetch {
 
60
      if (req.url == "/test.html") {
 
61
          set beresp.do_esi = true;  /* Do ESI processing */
 
62
      }
 
63
  }