@@ -65,8 +65,9 @@ Ensure Consistent Caching Behaviour
65
65
66
66
Varnish uses the cache headers sent by your application to determine how
67
67
to cache content. However, versions prior to Varnish 4 did not respect
68
- ``Cache-Control: no-cache ``. To ensure consistent behaviour, use the following
69
- configuration if you are still using Varnish 3:
68
+ ``Cache-Control: no-cache ``, ``no-store `` and ``private ``. To ensure
69
+ consistent behavior, use the following configuration if you are still
70
+ using Varnish 3:
70
71
71
72
.. configuration-block ::
72
73
@@ -76,13 +77,19 @@ configuration if you are still using Varnish 3:
76
77
/* By default, Varnish3 ignores Cache-Control: no-cache and private
77
78
https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control
78
79
*/
79
- if (beresp.http.Cache-Control ~ "no-cache" ||
80
- beresp.http.Cache-Control ~ "private"
80
+ if (beresp.http.Cache-Control ~ "private" ||
81
+ beresp.http.Cache-Control ~ "no-cache" ||
82
+ beresp.http.Cache-Control ~ "no-store"
81
83
) {
82
84
return (hit_for_pass);
83
85
}
84
86
}
85
87
88
+ .. tip ::
89
+
90
+ You can see the default behavior of Varnish in the form of a VCL file:
91
+ `default.vcl `_ for Varnish 3, `builtin.vcl `_ for Varnish 4.
92
+
86
93
Enable Edge Side Includes (ESI)
87
94
-------------------------------
88
95
@@ -143,7 +150,7 @@ Symfony adds automatically:
143
150
.. tip ::
144
151
145
152
If you followed the advice about ensuring a consistent caching
146
- behaviour , those vcl functions already exist. Just append the code
153
+ behavior , those vcl functions already exist. Just append the code
147
154
to the end of the function, they won't interfere with each other.
148
155
149
156
.. index ::
@@ -172,3 +179,5 @@ proxy before it has expired, it adds complexity to your caching setup.
172
179
.. _`Surrogate-Capability Header` : http://www.w3.org/TR/edge-arch
173
180
.. _`cache invalidation` : http://tools.ietf.org/html/rfc2616#section-13.10
174
181
.. _`FOSHttpCacheBundle` : http://foshttpcachebundle.readthedocs.org/
182
+ .. _`default.vcl` : https://www.varnish-cache.org/trac/browser/bin/varnishd/default.vcl?rev=3.0
183
+ .. _`builtin.vcl` : https://www.varnish-cache.org/trac/browser/bin/varnishd/builtin.vcl?rev=4.0
0 commit comments