Skip to content

Commit a44c05d

Browse files
committed
[dashboard] Improve handling of errors and cache headers
1 parent 3760f7e commit a44c05d

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

chart/config/proxy/lib.error-generic.conf

Lines changed: 0 additions & 10 deletions
This file was deleted.

chart/config/proxy/lib.locations.conf

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{{- $this := dict "root" . "gp" $.Values }}
22
include lib.resolver.conf;
3-
include lib.error-generic.conf;
4-
53

64
#######################################################
75
# Reverse-proxy for server service
@@ -23,14 +21,6 @@ location / {
2321
include lib.cors-headers.conf;
2422

2523
proxy_pass http://dashboard$request_uri;
26-
27-
# # # Page Not Found
28-
# # Let's redirect the browser agent to the web app, if no resources are found in the locations specified here.
29-
# #
30-
# # This is derived from the issue https://github.com/gitpod-io/gitpod/issues/2659, which
31-
# # was appearently caused by Twitter's link shortening. So, if the leading www is missing
32-
# # in the URL by accident, we will redirect to the web on 404 – Not Found.
33-
# error_page 404 @error_404_dashboard;
3424
}
3525

3626
# location @error_404_dashboard {
@@ -194,4 +184,4 @@ location @error_404 {
194184
location @error_generic {
195185
# Something really bad happened: One of the requested resources is not there, at all. Redirect to the generic error page
196186
return 302 {{ template "gitpod.scheme" $this }}://{{.Values.hostname}}/sorry/#Error%20$upstream_status;
197-
}
187+
}

components/dashboard/conf/Caddyfile

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,63 @@
1313
}
1414
}
1515

16-
:80 {
17-
@static {
16+
(static) {
17+
@static_path {
18+
path /static/*
19+
}
20+
21+
@static_asset {
22+
file
1823
path /static/*
1924
}
2025

21-
@notstatic {
26+
# static assets configure cache headers and do not check for changes
27+
header @static_asset {
28+
Cache-Control "public, max-age=31536000"
29+
# remove Last-Modified header
30+
-Last-Modified
31+
}
32+
}
33+
34+
(notstatic) {
35+
@not_static_path {
36+
not path /static/*
37+
}
38+
39+
@not_static_assets {
2240
not path /static/*
2341
}
2442

43+
header @not_static_assets {
44+
Cache-Control "no-cache, no-transform, must-revalidate"
45+
}
46+
}
47+
48+
:80 {
2549
import compression
2650
import discard_log
51+
import static
52+
import notstatic
2753

2854
redir /.well-known/security.txt https://www.gitpod.io/.well-known/security.txt permanent
2955
redir /environment-variables /settings/ permanent
3056

31-
handle @static {
32-
header Cache-Control "public, max-age=31536000"
33-
}
34-
35-
handle @notstatic {
36-
header Cache-Control "no-cache, no-transform, must-revalidate"
37-
}
38-
3957
header -Server
40-
header -Last-Modified
4158

4259
root * /www
4360
file_server
44-
try_files {path} {path}/ /index.html
61+
62+
handle @static_path {
63+
try_files {path}
64+
}
65+
66+
handle @not_static_path {
67+
try_files {path} {path}/ /index.html
68+
}
69+
70+
handle {
71+
respond "404 - Not Found" 404
72+
}
4573
}
4674

4775
# health-check

0 commit comments

Comments
 (0)