8000 Added config example for Varnish 4.0 · symfony/symfony-docs@df2086e · GitHub
[go: up one dir, main page]

Skip to content

Commit df2086e

Browse filesBrowse files
Added config example for Varnish 4.0
1 parent c332063 commit df2086e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

cookbook/cache/varnish.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,11 @@ Symfony adds automatically:
5757
.. code-block:: text
5858
5959
sub vcl_fetch {
60-
/*
61-
Check for ESI acknowledgement
62-
and remove Surrogate-Control header
63-
*/
60+
// Check for ESI acknowledgement and remove Surrogate-Control header
6461
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
6562
unset beresp.http.Surrogate-Control;
6663
67-
// For Varnish >= 3.0
64+
// For Varnish >= 3.0, < 4.0
6865
set beresp.do_esi = true;
6966
// For Varnish < 3.0
7067
// esi;
@@ -79,6 +76,24 @@ Symfony adds automatically:
7976
}
8077
}
8178
79+
/* For Varnish >= 4.0
80+
(https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#req-not-available-in-vcl-backend-response) */
81+
sub vcl_backend_response {
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+
86+
set beresp.do_esi = true;
87+
}
88+
if (beresp.http.Pragma ~ "no-cache" ||
89+
beresp.http.Cache-Control ~ "no-cache" ||
90+
beresp.http.Cache-Control ~ "private") {
91+
// https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#hit-for-pass-objects-are-created-using-beresp-uncacheable
92+
set beresp.uncacheable = true;
93+
return (deliver);
94+
}
95+
}
96+
8297
.. caution::
8398

8499
Compression with ESI was not supported in Varnish until version 3.0

0 commit comments

Comments
 (0)
0