Commit b37bb0ee authored by Per Andreas Buer's avatar Per Andreas Buer

rewrote VCL + removed all warnings

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4858 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d81fe0f4
......@@ -43,7 +43,7 @@ being:
You are probably best of compiling your own code. See `Compiling Varnish from source`_.
If that worked for you, you can skip the rest of this document
for now, and and start reading the much more interesting :ref:`Tutorial`
for now, and and start reading the much more interesting :ref:`tutorial-index`
instead.
......
......@@ -22,8 +22,8 @@ couple of really basic programs that can execute a HTTP request and
give you the result. I use two programs, GET and HEAD.
vg.no was the first site to use Varnish and the people running Varnish
there are quite clueful. So its interesting to look at their HTTP
Headers. Lets send a GET requst for their home page.::
there are quite cluefull. So its interesting to look at their HTTP
Headers. Lets send a GET request for their home page.::
$ GET -H 'Host: www.vg.no' -Used http://vg.no/
GET http://vg.no/
......@@ -81,9 +81,8 @@ The Cache-Control instructs caches how to handle the content. Varnish
cares about the *max-age* parameter and uses it to calculate the TTL
for an object.
"Cache-Control: nocache" is ignored. See
:ref:`tutorial-increasing_your_hitrate-pragma:` for an example on how
to implement support.
"Cache-Control: nocache" is ignored but if you need this you can
easyli add support for it.
So make sure use issue a Cache-Control header with a max-age
header. You can have a look at what Varnish Softwares drupal server
......
......@@ -65,5 +65,5 @@ give you a clue.
Varnish doesn't cache
~~~~~~~~~~~~~~~~~~~~~
See :ref:`_tutorial-increasing_your_hitrate:`.
See :ref:`tutorial-increasing_your_hitrate`.
Varnish Configuration Language - VCL
-------------------------------------
Varnish has a really neat configuration system. Most other systems use
configuration directives, where you basically turn on and off a bunch
of switches.
Varnish has a great configuration system. Most other systems use
configuration directives, where you basically turn on and off lots of
switches. Varnish uses a domain specific language called Varnish
Configuration Language, or VCL for short. Varnish translates this
configuration into binary code which is then executed when requests
arrive.
A very common thing to do in Varnish is to override the cache headers
from our backend. Lets see how this looks in Squid, which has a
standard configuration.::
refresh_pattern ^http://images. 3600 20% 7200
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern -i (/\.jpg) 1800 10% 3600 override-expire
refresh_pattern . 0 20% 4320
If you are familiar with squid that probably made sense to you. But
lets point out a few weaknesses with this model.
1) It's not intuitive. You can guess what the options mean, and you
can (and should) document it in your configuration file.
2) Which rules have precedence? Does the last rule to match stick? Or
the first? Or does Squid try to combine all the matching rules. I
actually don't know.
Now enter Varnish. Varnish takes your configuration file and
translates it to C code, then runs it through a compiler and loads
it. When requests come along varnish just executes the relevant
subroutines of the configuration at the relevant times.
The VCL files are divided into subroutines. The different subroutines
are executed at different times. One is executed when we get the
request, another when files are fetched from the backend server.
Varnish will execute these subroutines of code at different stages of
its work. Since its code it's execute line by line and precedence
its work. Because it is code it is execute line by line precedence
isn't a problem. At some point you call an action in this subroutine
and then the execution of the subroutine stops.
and then the execution of the subroutine stops.
If you don't call an action in your subroutine and it reaches the end
Varnish will execute some built in code as well. We discuss this in
XXX: Appendix A - the builtin VCL.
Varnish will execute some built in VCL code. You will see this VCL
code commented out in default.vcl.
99% of all the changes you'll need to do will be done in two of these
subroutines.
subroutines. vcl_recv and vcl_fetch.
vcl_recv
~~~~~~~~
......
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