Permalink
Browse files

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
  • Loading branch information...
weaverryan committed Jun 13, 2014
2 parents 8fef7b7 + 3a94e1f commit 6cba0f129056a4ac20f7a84cc069d7e726a090b4
Showing with 8 additions and 0 deletions.
  1. +8 −0 cookbook/cache/varnish.rst
@@ -57,6 +57,14 @@ Symfony2 adds automatically:
// For Varnish < 3.0
// esi;
}
/* By default Varnish ignores Cache-Control: nocache
(https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control),
so in order avoid caching it has to be done explicitly */
if (beresp.http.Pragma ~ "no-cache" ||
beresp.http.Cache-Control ~ "no-cache" ||
beresp.http.Cache-Control ~ "private") {
return (hit_for_pass);
}
}
.. caution::

0 comments on commit 6cba0f1

Please sign in to comment.