Skip to content

Commit

Permalink
[dashboard] Improve handling of errors and cache headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Apr 14, 2021
1 parent 3760f7e commit a44c05d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
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

0 comments on commit a44c05d

Please sign in to comment.