Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit507fd72

Browse files
Added config example for Varnish 4.0
1 parentc332063 commit507fd72

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

‎cookbook/cache/varnish.rst‎

Lines changed: 26 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,30 @@ Symfony adds automatically:
7976
}
8077
}
8178
79+
/**
80+
* For Varnish >= 4.0
81+
* https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#req-not-available-in-vcl-backend-response
82+
*/
83+
sub vcl_backend_response {
84+
// Check for ESI acknowledgement and remove Surrogate-Control header
85+
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
86+
unset beresp.http.Surrogate-Control;
87+
88+
set beresp.do_esi = true;
89+
}
90+
// By default Varnish ignores Cache-Control: nocache
91+
// (https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control),
92+
// so in order avoid caching it has to be done explicitly
93+
if (beresp.http.Pragma ~ "no-cache" ||
94+
beresp.http.Cache-Control ~ "no-cache" ||
95+
beresp.http.Cache-Control ~ "private") {
96+
// https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#hit-for-pass-objects-are-created-using-beresp-uncacheable
97+
set beresp.uncacheable = true;
98+
set beresp.ttl = 120s;
99+
return (deliver);
100+
}
101+
}
102+
82103
..caution::
83104

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp