Skip to content

Commit

Permalink
feature #4801 [Cookbook][cache][varnish] be more precise about versio…
Browse files Browse the repository at this point in the history
…n differences (dbu)

This PR was merged into the 2.3 branch.

Discussion
----------

[Cookbook][cache][varnish] be more precise about version differences

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | all
| Fixed tickets | -

Found this page while trying to figure out what exactly the defaults of varnish are, and realized I was not precise yet.

Commits
-------

dc2829c [varnish] be more precise about version differences
  • Loading branch information
weaverryan committed Jan 21, 2015
2 parents bcf1508 + dc2829c commit 3293286
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cookbook/cache/varnish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ Ensure Consistent Caching Behaviour

Varnish uses the cache headers sent by your application to determine how
to cache content. However, versions prior to Varnish 4 did not respect
``Cache-Control: no-cache``. To ensure consistent behaviour, use the following
configuration if you are still using Varnish 3:
``Cache-Control: no-cache``, ``no-store`` and ``private``. To ensure
consistent behavior, use the following configuration if you are still
using Varnish 3:

.. configuration-block::

Expand All @@ -76,13 +77,19 @@ configuration if you are still using Varnish 3:
/* By default, Varnish3 ignores Cache-Control: no-cache and private
https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control
*/
if (beresp.http.Cache-Control ~ "no-cache" ||
beresp.http.Cache-Control ~ "private"
if (beresp.http.Cache-Control ~ "private" ||
beresp.http.Cache-Control ~ "no-cache" ||
beresp.http.Cache-Control ~ "no-store"
) {
return (hit_for_pass);
}
}
.. tip::

You can see the default behavior of Varnish in the form of a VCL file:
`default.vcl`_ for Varnish 3, `builtin.vcl`_ for Varnish 4.

Enable Edge Side Includes (ESI)
-------------------------------

Expand Down Expand Up @@ -143,7 +150,7 @@ Symfony adds automatically:
.. tip::

If you followed the advice about ensuring a consistent caching
behaviour, those vcl functions already exist. Just append the code
behavior, those vcl functions already exist. Just append the code
to the end of the function, they won't interfere with each other.

.. index::
Expand Down Expand Up @@ -172,3 +179,5 @@ proxy before it has expired, it adds complexity to your caching setup.
.. _`Surrogate-Capability Header`: http://www.w3.org/TR/edge-arch
.. _`cache invalidation`: http://tools.ietf.org/html/rfc2616#section-13.10
.. _`FOSHttpCacheBundle`: http://foshttpcachebundle.readthedocs.org/
.. _`default.vcl`: https://www.varnish-cache.org/trac/browser/bin/varnishd/default.vcl?rev=3.0
.. _`builtin.vcl`: https://www.varnish-cache.org/trac/browser/bin/varnishd/builtin.vcl?rev=4.0

0 comments on commit 3293286

Please sign in to comment.