8000 Varnish only takes into account max-age · symfony/symfony-docs@f958391 · GitHub
[go: up one dir, main page]

Skip to content

Commit f958391

Browse files
Varnish only takes into account max-age
Varnish only takes into account max-age, Symfony by default returns Cache-Control: no-cache so Varnish caches it anyway. You need to specify: ``` if (beresp.http.Pragma ~ "no-cache" || beresp.http.Cache-Control ~ "no-cache" || beresp.http.Cache-Control ~ "private") { return (hit_for_pass); } ``` In order to avoid Varnish from caching content.
1 parent 140e54e commit f958391

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cookbook/cache/varnish.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ Symfony2 adds automatically:
5757
// For Varnish < 3.0
5858
// esi;
5959
}
60+
/* Do not cache if no-cache is found in headers */
61+
if (beresp.http.Pragma ~ "no-cache" ||
62+
beresp.http.Cache-Control ~ "no-cache" ||
63+
beresp.http.Cache-Control ~ "private") {
64+
return (hit_for_pass);
65+
}
6066
}
6167
6268
.. caution::

0 commit comments

Comments
 (0)
0