Skip to content

Commit 9be7706

Browse files
committed
Auto merge of #2384 - jtgeibel:server-more-static-assets-from-nginx, r=carols10cents
Serve more static files from nginx 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 #2252 r? @carols10cents
2 parents 9e47a17 + 45c7511 commit 9be7706

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

config/nginx.conf.erb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,27 @@ http {
132132
server_name _;
133133
keepalive_timeout 5;
134134

135-
location ~ ^/assets/ {
135+
location ~ ^/(assets|ember-fetch|moment)/ {
136136
add_header X-Content-Type-Options nosniff;
137137
add_header Cache-Control public;
138138
root dist;
139139
expires max;
140140
}
141141

142+
location ~ ^/cargo-[0-9a-f]*\.png$ {
143+
add_header X-Content-Type-Options nosniff;
144+
add_header Cache-Control public;
145+
root dist;
146+
expires max;
147+
}
148+
149+
location ~ /(favicon\.ico|robots\.txt|opensearch\.xml) {
150+
add_header X-Content-Type-Options nosniff;
151+
add_header Cache-Control public;
152+
root dist;
153+
expires 1d;
154+
}
155+
142156
add_header X-Content-Type-Options "nosniff";
143157
add_header X-Frame-Options "SAMEORIGIN";
144158
add_header X-XSS-Protection "1; mode=block";

0 commit comments

Comments
 (0)