Skip to content
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

Incomplete cookbook entry about Varnish + ESI ? #3881

Closed
greg0ire opened this issue May 27, 2014 · 6 comments
Closed

Incomplete cookbook entry about Varnish + ESI ? #3881

greg0ire opened this issue May 27, 2014 · 6 comments
Labels

Comments

@greg0ire
Copy link
Contributor

I was struggling with ESI today, when I stumbled upon this SO question.
The cookbook entry about ESI doesn't talk about session cookies, and it seems that they prevent cache lookups (when in the request) and caching (when in the response) (at least when you start from the default VCL configuration and apply the changes documented in the cookbook entry).
Following the cookbook entry leads to a working html page, but with no caching. Shouldn't this be documented ?

@greg0ire greg0ire changed the title Incomplete cookbook entry about Varnish + ESI Incomplete cookbook entry about Varnish + ESI ? May 27, 2014
@weaverryan weaverryan added the Bug label Jun 7, 2014
@weaverryan
Copy link
Member

I agree - this is incomplete as it is now - someone needs to really go through a Varnish setup with Symfony and outline all the steps and things to watch out for. We don't need to rewrite any Varnish docs, we just need a guide on how to navigate through Varnish and Symfony (including details about cookies, recommendations, and links to Varnish docs).

A big +1 for this.

@greg0ire
Copy link
Contributor Author

greg0ire commented Jun 9, 2014

The new docs should probably answer the following questions :

  1. When developing, should one use the built-in reverse proxy or Varnish?
    1. If yes, how can one make sure this reverse proxy is used only in the development environment ?
    2. If not, what program should listen on which port ? How should SSL be dealt with ?
  2. How should Varnish decide to remove the cookies ?
  3. How can one check that Varnish is in use ?

My answers to these questions (open for discussion, may be completely wrong) :

  1. I think the reverse proxy should be used when trying to setup caching in the application, and once it works, Varnish should be used, so that the dev environment stays similar to the production environment.
    1. No idea.
    2. I think Varnish should listen on port 80, and the webserver behind it on whatever you choose. I don't know how to deal with SSL on a development machine though. That would probably require setting up haproxy before it like we do on our production machine.
  2. If you use sonata page bundle, the url pattern is a good thing to look at. Otherwise, I think the presence of a Shared-Max-Age header is a good indicator that a page is meant to be cached.
  3. One can look at their web server access logs, and if there are less requests after the first request, it probably works.

@lyrixx
Copy link
Member

lyrixx commented Jun 9, 2014

I think the presence of a Shared-Max-Age header is a good indicator that a page is meant to be cached.

It's exactly what I do in my varnish conf. If the response has a smax-age, I do remove cookie.

But we can not document that. It's too specific and too important. One can mess the conf and break the security layer. People should understand how varnish + http + symfony work. And then they can tweak the config.

Anyway, if there is no cookie in the response, varnish is able to cache...

@greg0ire
Copy link
Contributor Author

greg0ire commented Jun 9, 2014

But we can not document that.

@lyrixx : so what would you recommend instead ? Links to the Varnish documentation about cookies, and nothing more, so that people figure something out by themselves ?

@lyrixx
Copy link
Member

lyrixx commented Jun 9, 2014

Good idea ;)

@dbu
Copy link
Contributor

dbu commented Aug 25, 2014

is there no more elegant solution about the cookie problem than unsetting it in varnish? can't symfony determine if it needs a session or not?

(i asked the same question in #4141 - maybe you can give input there as well. with regard to #4175 i hope to review the caching documentation and propose improvements)

weaverryan added a commit that referenced this issue Jan 30, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

Varnish cookbook session cookie handling

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | #3881

This builds on top of #4627 but i wanted to keep it separate as there are open questions in here.

Commits
-------

b294b24 cleanup from feedback
7a4dafc remove part about vary on cookie
c88ad32 explain how to work with cookies and sessions when caching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants