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 6cba0f1

Browse filesBrowse files
committed
feature #3936 Varnish only takes into account max-age (gonzalovilaseca)
This PR was submitted for the 2.5 branch but it was merged into the 2.3 branch instead (closes #3936). Discussion ---------- Varnish only takes into account max-age | Q | A | ------------- | --- | Doc fix? | [no] | New docs? | [no] (PR # on symfony/symfony if applicable) | Applies to | [Symfony version 2.3] | Fixed tickets | 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. Commits ------- 466bd6a Update varnish.rst 8848549 Update varnish.rst f958391 Varnish only takes into account max-age
2 parents 8fef7b7 + 3a94e1f commit 6cba0f1
Copy full SHA for 6cba0f1

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎cookbook/cache/varnish.rst

Copy file name to clipboardExpand all lines: cookbook/cache/varnish.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ Symfony2 adds automatically:
5757
// For Varnish < 3.0
5858
// esi;
5959
}
60+
/* By default Varnish ignores Cache-Control: nocache
61+
(https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control),
62+
so in order avoid caching it has to be done explicitly */
63+
if (beresp.http.Pragma ~ "no-cache" ||
64+
beresp.http.Cache-Control ~ "no-cache" ||
65+
beresp.http.Cache-Control ~ "private") {
66+
return (hit_for_pass);
67+
}
6068
}
6169
6270
.. caution::

0 commit comments

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