Opened 3 years ago

Closed 3 years ago

#32212 closed Uncategorized (wontfix)

Vary header changed by SessionMiddleware

Reported by: y p Owned by: nobody
Component: Uncategorized Version: 2.2
Severity: Normal Keywords: cache Vary SessionMiddleware
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by y p)

To specify the cache mode, i use the view decorator like this:

@vary_on_headers('Accept', 'Accept-Language', 'Origin')
@cache_control(public=True, max_age=3600)

But after tracing, I found that SessionMiddleware modified the Vary Header and added a Cookie, as follows:

if accessed:
    patch_vary_headers(response, ('Cookie',))

Causes cache invalidation after user login again.
I have specified the cache as public, in which case the cache scheme should have nothing to do with cookies.

Change History (2)

comment:1 by y p, 3 years ago

Description: modified (diff)

comment:2 by Carlton Gibson, 3 years ago

Resolution: wontfix
Status: newclosed

I'm afraid this is as-designed. It's just how session middleware works. See #3586 for the change implementing the current behaviour.

If you need hard caching here then serve the "static" pages from a separate app, without Session middleware, and use JavaScript to load the user-specific sections.

Note: See TracTickets for help on using tickets.
Back to Top