8000 Varnish only takes into account max-age by gonzalovilaseca · Pull Request #3936 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Varnish only takes into account max-age #3936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
gonzalovilaseca committed Jun 11, 2014
commit f958391bb74c9a63fc2050b85e401e195f36914b
6 changes: 6 additions & 0 deletions cookbook/cache/varnish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ Symfony2 adds automatically:
// For Varnish < 3.0
// esi;
}
/* Do not cache if no-cache is found in headers */
if (beresp.http.Pragma ~ "no-cache" ||
beresp.http.Cache-Control ~ "no-cache" ||
beresp.http.Cache-Control ~ "private") {
return (hit_for_pass);
}
}

.. caution::
Expand Down
0