Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Varnish cookbook session cookie handling#4628

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 3 commits intosymfony:2.3fromdbu:varnish-cookbook-session-cookie-handling
Jan 30, 2015
Merged

Varnish cookbook session cookie handling#4628

weaverryan merged 3 commits intosymfony:2.3fromdbu:varnish-cookbook-session-cookie-handling
Jan 30, 2015

Conversation

@dbu
Copy link
Contributor

@dbudbu commentedDec 11, 2014

QA
Doc fix?yes
New docs?no
Applies toall
Fixed tickets#3881

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

this section is the only addition compared to#4627

Copy link
Contributor

Choose a reason for hiding this comment

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

most headlines are in "Gerund", so i am 👎 to change this.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

wait, please comment on#4627 for this

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

the only new section compared to#4627 in here is "Session Cookies and Caching"

Copy link
Member

Choose a reason for hiding this comment

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

why are you putting braces here ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

the only new section compared to#4627 in here is "Session Cookies and Caching"

but you are right that this is weird. i just reformatted this section, did not change the content. but will have another look into this.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

because it was there before. bad excuse. fixed.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

in#4627, that is

Copy link
Member

Choose a reason for hiding this comment

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

In practical terms, what should this mean to the user? I think it means that you're telling Varnish toyes be ok with caching requests that contain cookies. And so, as a user, you must be very careful tonot rely on the session for any parts of your page where you return caching headers. If you violate this rule, then you will cache something with - for example - a user's username in it.

Is this about right? I want to walk the user through this as much as possible. For me, it seems that you should be (as you elude to here) identifying which portions of your page need the session, isolating them into non-cached ESI fragments, then caching the whole page (or doing a complete opposite strategy where you isolate non-session-needing heavy pieces, then don't cache the whole page).

The point is, this is non-trivial, so perhaps we need to walk them through a bit more tutorial-styled.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I still mean everything I said, but most of what I said should be in the book. I still think we can add a few more details, like those I have in my first paragraph.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

i tried to make this more explicit, and also added a warning at the end of the section.

@dbudbu changed the title[WIP] Varnish cookbook session cookie handlingVarnish cookbook session cookie handlingDec 25, 2014
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think we should suggest varying based on cookies. this is just useable if you vary on flags (Terms, Users Age, ...)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

i disagree. assume i have one url/_fragment/user/toolbar that renders the user name into every page. the rest of the content does not vary on cookie, but this one url does. and its embedded with ESI into every page. then we would want to cache this url as a variant for every single user to avoid reloading it all the time. once you log out, your session will be destroyed, meaning the session cookie changes and thus you don't see your username anymore.

obviously, you need to clean the cookie string for this to work, you don't want any js cookies irrelevant for the backend in here.

Copy link
Contributor

Choose a reason for hiding this comment

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

you could also store the username in a cookie / localstorage or something else to print it. from my point of view storing user specific content in the reverse proxy can be a good idea but most time you should try to avoid it. people could think it's a good idea to mess up the cache with a Vary on the Cookie. This issue is hard to find for newbies because most times, if they test they use the same cookie. Why not creating a advanced cookbook where we explain how to cache based on Cookies (Javascript), Cookies + Vary (Varnish), Localstorage, ....

@dbu
Copy link
ContributorAuthor

dbu commentedDec 28, 2014

@timglabisch copied your comment from a line that was now changed:

you could also store the username in a cookie / localstorage or something else to print it. from my point of view storing user specific content in the reverse proxy can be a good idea but most time you should try to avoid it. people could think it's a good idea to mess up the cache with a Vary on the Cookie. This issue is hard to find for newbies because most times, if they test they use the same cookie. Why not creating a advanced cookbook where we explain how to cache based on Cookies (Javascript), Cookies + Vary (Varnish), Localstorage, ....

the problem is that saying to cache even when there are cookies is pretty dangerous. but stripping all cookies including the session is a really good trick to break your knees...

this somewhat touches#4661 - somebody could either expand that one or add a separate receipie to the cookbook. i do not plan to do that right now (its been a while that i even worked with a html frontend and varnish, currently i am caching APIs :-) ). so what do we do? should i just drop the bit about ESI and vary on cookie? or mention it in 5 words and let people wonder how it actually can be done?

Copy link
Contributor

Choose a reason for hiding this comment

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

why not dropping the word "Session", it's for all Cookies.

@timglabisch
Copy link
Contributor

my problem is that this PR suggests that using vary on the cookie header is the way to go. i would do a lot to avoid caching based on a user specific cookie, for me this is more like an antipattern that can work in some situations. Don't get me wrong, the PR provides a useable way, but i would like the reader to know that there are alternative ways to solve such problems. if the page could be cached based on a user specific cookie, most time it's not worth to be cached at all. if you're running a huge varnish cluster without stickiness you even can hurt the performance. I am 👍 with this PR but would love to see a hint that there are a lot of caching strategies with different advantages and disadvantages.

@dbu
Copy link
ContributorAuthor

dbu commentedDec 31, 2014

i removed the part about vary on cookie as it is indeed very specific. this is now rather short and just giving some pointers and basic considerations. the rest of the question is not varnish specific and should go into#4141,#4661 and possibly some features / doc in FOSHttpCacheBundle

Copy link
Member

Choose a reason for hiding this comment

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

what about linking directly to the relevant page of the bundle documentation ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

good idea. linked.

* link user context to relevant section of the doc* better explain what we achieve with cleaning the cookies
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

eliminated one of the TODOs .#4661 is still not merged, so i can't link to that. can we wrap those up?

Copy link
Member

Choose a reason for hiding this comment

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

I think#4661 is kind of blocked because of the difficulty of the topic - you have 1 open question and 1 todo on that issue that I can't answer without some time to look into things.

As an aside, for me, this smells like a bug or missing feature in Symfony. I think the PRsymfony/symfony#6388 or issuesymfony/symfony#6036 need to be finally pushed along - the functionality just isn't right. Of course, that's an even bigger task.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

okay. can we get this PR merged then? looks like the session start issue is a potentially long story.

or do you not want todos in the doc code? should we create a new issue to remind us that when#4661 is merged we add a reference in this section of the doc.

@weaverryan
Copy link
Member

Yep, we'll keep that todo in there for now. Thanks for giving these sections much-needed updates. Cheers!

@weaverryanweaverryan merged commitb294b24 intosymfony:2.3Jan 30, 2015
weaverryan added a commit that referenced this pull requestJan 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 |#3881This builds on top of#4627 but i wanted to keep it separate as there are open questions in here.Commits-------b294b24 cleanup from feedback7a4dafc remove part about vary on cookiec88ad32 explain how to work with cookies and sessions when caching
@dbudbu deleted the varnish-cookbook-session-cookie-handling branchFebruary 20, 2015 15:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@dbu@timglabisch@weaverryan@stof@wouterj@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp