Set-Cookie header is injected into static content requests, breaking caching.
See original GitHub issueRight now, if LoginManager()
is installed in a flask-app, it adds a set-cookie
header to ALL requests, including static content.
This breaks (at least) Nginx reverse-proxy caching, as nginx disables caching if it sees a set-cookie header, even if the flask app itself returns the proper HTTP 304 for the relevant resource.
Realistically, setting cookies on static content is kind of silly anyways, and probably shouldn’t happen in the first place.
It’d be nice if flask-login only set cookies on things that actually can change.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Caching content based on cookies - Amazon CloudFront
CloudFront caches the response using the listed cookies names and values in the viewer request. If the origin response includes Set-Cookie headers, CloudFront ......
Read more >Cloudfront removes Set-Cookie header from response to viewer
I have a NextJs application running in an AWS EC2 instance. The application includes static pages and APIs for login. Now, I am...
Read more >Mastering HTTP Caching | fortrabbit blog
This request header makes clear, that the client would accept either a full response or a response indicating that the content was not...
Read more >Adding Cache-Control headers to Static Files in ASP.NET Core
In this post I'll show how you can add caching headers to the files served by the StaticFileMiddleware to increase your site's performance....
Read more >Setting a Set-Cookie - ignore or accept | CDN Static - CDNsun
Using the Set-Cookie HTTP response header a server can pass data (cookies) to a browser. When the browser makes subsequent requests to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Garrett-R: you saved my day!
Wanted to mention I had this same issue and give the solution for future readers.
Turns out that if your app makes any call to
flask_login.current_user
, then the Flask session will (unsurprisingly) be accessed. On any request where the session is accessed, Flask (surprisingly) will add theVary: cookie
header to the response (perhaps also theSet-Cookie
header, but it’s theVary
header responsible for caching problems). Here was my solution.