Skip to content

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!

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