Skip to content

[dashboard] Improve handling of errors and cache headers #3935

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

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions chart/config/proxy/lib.error-generic.conf

This file was deleted.

12 changes: 1 addition & 11 deletions chart/config/proxy/lib.locations.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{- $this := dict "root" . "gp" $.Values }}
include lib.resolver.conf;
include lib.error-generic.conf;


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

proxy_pass http://dashboard$request_uri;

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

# location @error_404_dashboard {
Expand Down Expand Up @@ -194,4 +184,4 @@ location @error_404 {
location @error_generic {
# Something really bad happened: One of the requested resources is not there, at all. Redirect to the generic error page
return 302 {{ template "gitpod.scheme" $this }}://{{.Values.hostname}}/sorry/#Error%20$upstream_status;
}
}
54 changes: 41 additions & 13 deletions components/dashboard/conf/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,63 @@
}
}

:80 {
@static {
(static) {
@static_path {
path /static/*
}

@static_asset {
file
path /static/*
}

@notstatic {
# static assets configure cache headers and do not check for changes
header @static_asset {
Cache-Control "public, max-age=31536000"
# remove Last-Modified header
-Last-Modified
}
}

(notstatic) {
@not_static_path {
not path /static/*
}

@not_static_assets {
not path /static/*
}

header @not_static_assets {
Cache-Control "no-cache, no-transform, must-revalidate"
}
}

:80 {
import compression
import discard_log
import static
import notstatic

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

handle @static {
header Cache-Control "public, max-age=31536000"
}

handle @notstatic {
header Cache-Control "no-cache, no-transform, must-revalidate"
}

header -Server
header -Last-Modified

root * /www
file_server
try_files {path} {path}/ /index.html

handle @static_path {
try_files {path}
}

handle @not_static_path {
try_files {path} {path}/ /index.html
}

handle {
respond "404 - Not Found" 404
}
}

# health-check
Expand Down