-
Notifications
You must be signed in to change notification settings - Fork 628
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
Serve more static files from nginx #2384
Serve more static files from nginx #2384
Conversation
Serve more folders containing files with hashed filenames directly from nginx with a max expiration date. Additionally, some unhashed static files are allowed to be cached for up to 1 day. These changes serve as a workaround for an authentication issue. Currently `conduit-cookie` includes a `Set-Cookie` header in every backend response. During the authentication steps, the popup window requests static assets such as `favicon.ico` and `cargo-{hash}.png`. If these assets are served by the backend, they will echo whatever cookie was sent in the request. Therefore, there is a race between the request to `/api/private/session/authorize?...` and requests for these static assets. If a request for one of these assets is sent before authorization is complete and the response arrives after successful authorization, then the stale cookie will be stored again by the browser, overwriting the contents. I've opened conduit-rust/conduit-cookie#12 to track the progress of the proposed long-term solution. This commit should be sufficient to fix the behavior for now and should reduce the number of requests for these static assets (due to improved caching). Closes rust-lang#2252 r? @carols10cents
wow... how on earth did you figure that one out?! 😱 |
Yeah, this took a lot of time to track down! Every time I thought I had reproduction steps or saw a pattern, everything would start working again. I tried all sorts of things like: reloading the page at different points, deleting the cookie as if it had expired, adding extra cookies, and even manually setting I couldn't find a way to use the developer tools within the short-lived popup window, so I eventually took a closer look at the staging logs. The extra requests to |
Whew! lgtm! Great work tracking this down! ❤️ @bors r+ |
📌 Commit 45c7511 has been approved by |
☀️ Test successful - checks-travis |
Serve more folders containing files with hashed filenames directly from
nginx with a max expiration date. Additionally, some unhashed static
files are allowed to be cached for up to 1 day.
These changes serve as a workaround for an authentication issue.
Currently
conduit-cookie
includes aSet-Cookie
header in everybackend response. During the authentication steps, the popup window
requests static assets such as
favicon.ico
andcargo-{hash}.png
.If these assets are served by the backend, they will echo whatever
cookie was sent in the request. Therefore, there is a race between the
request to
/api/private/session/authorize?...
and requests for thesestatic assets. If a request for one of these assets is sent before
authorization is complete and the response arrives after successful
authorization, then the stale cookie will be stored again by the
browser, overwriting the contents.
I've opened conduit-rust/conduit-cookie#12 to track the progress of the
proposed long-term solution. This commit should be sufficient to fix
the behavior for now and should reduce the number of requests for these
static assets (due to improved caching).
Closes #2252
r? @carols10cents