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

Varnish only takes into account max-age #3936

wants to merge 3 commits into from

Conversation

gonzalovilaseca
Copy link
Contributor
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.

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.
@weaverryan
Copy link
Member

Wow, it looks like you're right (https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control).

What do you think about adding a little note in your comment that says that Varnish ignores the no-cache by default and include the link from above? I want to leave "breadcrumbs" for readers later when they see this.

@gonzalovilaseca
Copy link
Contributor Author

Done!

@@ -57,6 +57,13 @@ 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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please put the url on a new line? That way, people don't have to do the quirckly horizontal scroll & select thing to select the url.

@weaverryan
Copy link
Member

This is an awesome find and a great note/addition. Thankss Gonzalo for it and the quick tweaks - we hope to see you back here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0