#23939: SessionAuthenticationMiddleware causes "Vary: Cookie" header no matter 
what
------------------------------+--------------------------------------
     Reporter:  andrewbadr    |                    Owner:  nobody
         Type:  Bug           |                   Status:  new
    Component:  contrib.auth  |                  Version:  1.7
     Severity:  Normal        |               Resolution:
     Keywords:  cookies       |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------

Comment (by carljm):

 I don't think "document the limitation" is an acceptable answer here.
 Adding `Vary: Cookie` unconditionally to all requests has massive
 implications for caching of requests that otherwise would not vary per-
 user. I know some large sites work hard to avoid `Vary: Cookie` on certain
 responses in order to make them cacheable without having to cache
 separately per-client.

 I think `SessionAuthenticationMiddleware` should be implemented quite
 differently, probably not as a middleware at all, but rather as code that
 runs lazily when `request.user` is first used (that is, in the `get_user`
 helper function).

 We should also add a simple test somewhere in the test suite that sets up
 a view which never accesses the session (or `request.user`, which
 implicitly accesses the session), and then calls that view with an end-to-
 end test passing through all the default middleware, and asserts that
 `Vary: Cookie' is not added to its responses. These bugs are way too easy
 to introduce, and we need a general test like that to prevent regressions
 of this type.

--
Ticket URL: <https://code.djangoproject.com/ticket/23939#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.166124b5344f9e8437709b264df69c63%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to