Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de286e2

Browse filesBrowse files
committed
Merge branch '2.3' into 2.5
* 2.3: "Revert "Added config example for Varnish 4.0"""
2 parents b582e4e + b3d96b8 commit de286e2
Copy full SHA for de286e2

File tree

Expand file treeCollapse file tree

1 file changed

+20
-52
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-52
lines changed

‎cookbook/cache/varnish.rst

Copy file name to clipboardExpand all lines: cookbook/cache/varnish.rst
+20-52Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,62 +54,30 @@ Then, optimize Varnish so that it only parses the Response contents when there
5454
is at least one ESI tag by checking the ``Surrogate-Control`` header that
5555
Symfony adds automatically:
5656

57-
.. configuration-block::
57+
.. code-block:: text
5858
59-
.. code-block:: varnish4
59+
sub vcl_fetch {
60+
/*
61+
Check for ESI acknowledgement
62+
and remove Surrogate-Control header
63+
*/
64+
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
65+
unset beresp.http.Surrogate-Control;
6066
61-
/* (https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#req-not-available-in-vcl-backend-response) */
62-
sub vcl_backend_response {
63-
// Check for ESI acknowledgement and remove Surrogate-Control header
64-
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
65-
unset beresp.http.Surrogate-Control;
66-
set beresp.do_esi = true;
67-
}
68-
/* By default Varnish ignores Pragma: nocache
69-
(https://www.varnish-cache.org/docs/4.0/users-guide/increasing-your-hitrate.html#cache-control)
70-
so in order avoid caching it has to be done explicitly */
71-
if (beresp.http.Pragma ~ "no-cache") {
72-
// https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#hit-for-pass-objects-are-created-using-beresp-uncacheable
73-
set beresp.uncacheable = true;
74-
set beresp.ttl = 120s;
75-
return (deliver);
76-
}
67+
// For Varnish >= 3.0
68+
set beresp.do_esi = true;
69+
// For Varnish < 3.0
70+
// esi;
7771
}
78-
79-
.. code-block:: varnish3
80-
81-
sub vcl_fetch {
82-
// Check for ESI acknowledgement and remove Surrogate-Control header
83-
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
84-
unset beresp.http.Surrogate-Control;
85-
set beresp.do_esi = true;
86-
}
87-
/* By default Varnish ignores Cache-Control: nocache
88-
(https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control),
89-
so in order avoid caching it has to be done explicitly */
90-
if (beresp.http.Pragma ~ "no-cache" ||
91-
beresp.http.Cache-Control ~ "no-cache" ||
92-
beresp.http.Cache-Control ~ "private") {
93-
return (hit_for_pass);
94-
}
95-
}
96-
97-
.. code-block:: varnish2
98-
99-
sub vcl_fetch {
100-
// Check for ESI acknowledgement and remove Surrogate-Control header
101-
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
102-
unset beresp.http.Surrogate-Control;
103-
esi;
104-
}
105-
/* By default Varnish ignores Cache-Control: nocache
106-
so in order avoid caching it has to be done explicitly */
107-
if (beresp.http.Pragma ~ "no-cache" ||
108-
beresp.http.Cache-Control ~ "no-cache" ||
109-
beresp.http.Cache-Control ~ "private") {
110-
return (hit_for_pass);
111-
}
72+
/* By default Varnish ignores Cache-Control: nocache
73+
(https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control),
74+
so in order avoid caching it has to be done explicitly */
75+
if (beresp.http.Pragma ~ "no-cache" ||
76+
beresp.http.Cache-Control ~ "no-cache" ||
77+
beresp.http.Cache-Control ~ "private") {
78+
return (hit_for_pass);
11279
}
80+
}
11381
11482
.. caution::
11583

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.