Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[Cookbook][Cache] Added config example for Varnish 4.0#4280
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
weaverryan merged 1 commit intosymfony:2.3fromthierrymarianne:add_config_for_varnish_4.0Oct 28, 2014
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
72 changes: 52 additions & 20 deletionscookbook/cache/varnish.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -54,30 +54,62 @@ Then, optimize Varnish so that it only parses the Response contents when there | ||
| is at least one ESI tag by checking the ``Surrogate-Control`` header that | ||
| Symfony adds automatically: | ||
| ..configuration-block:: | ||
| .. code-block:: varnish4 | ||
| /* (https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#req-not-available-in-vcl-backend-response) */ | ||
| sub vcl_backend_response { | ||
| // Check for ESI acknowledgement and remove Surrogate-Control header | ||
| if (beresp.http.Surrogate-Control ~ "ESI/1.0") { | ||
| unset beresp.http.Surrogate-Control; | ||
| set beresp.do_esi = true; | ||
| } | ||
| /* By default Varnish ignores Pragma: nocache | ||
| (https://www.varnish-cache.org/docs/4.0/users-guide/increasing-your-hitrate.html#cache-control) | ||
| so in order avoid caching it has to be done explicitly */ | ||
| if (beresp.http.Pragma ~ "no-cache") { | ||
| // https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html#hit-for-pass-objects-are-created-using-beresp-uncacheable | ||
| set beresp.uncacheable = true; | ||
| set beresp.ttl = 120s; | ||
| return (deliver); | ||
| } | ||
| } | ||
| .. code-block:: varnish3 | ||
| sub vcl_fetch { | ||
| // Check for ESI acknowledgement and remove Surrogate-Control header | ||
| if (beresp.http.Surrogate-Control ~ "ESI/1.0") { | ||
| unset beresp.http.Surrogate-Control; | ||
| set beresp.do_esi = true; | ||
| } | ||
| /* 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); | ||
| } | ||
| } | ||
| .. code-block:: varnish2 | ||
| sub vcl_fetch { | ||
| // Check for ESI acknowledgement and remove Surrogate-Control header | ||
| if (beresp.http.Surrogate-Control ~ "ESI/1.0") { | ||
| unset beresp.http.Surrogate-Control; | ||
| esi; | ||
| } | ||
| /* By default Varnish ignores Cache-Control: nocache | ||
| 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); | ||
| } | ||
| } | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. There should be blank line between the code block and the | ||
| .. caution:: | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.