Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd38e29

Browse files
authored
fix: make non-existent asset paths return a 404 (#14472)
Before, if a file was not found we would serve the app.This would cause either the login page or the workspacepage to load (and consequently error because `assets` islikely not a valid user).
1 parentef7fcf3 commitcd38e29

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎site/site.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
205205
casereqFile=="bin"||strings.HasPrefix(reqFile,"bin/"):
206206
h.handler.ServeHTTP(rw,r)
207207
return
208+
// If requesting assets, serve straight up with caching.
209+
casereqFile=="assets"||strings.HasPrefix(reqFile,"assets/"):
210+
// It could make sense to cache 404s, but the problem is that during an
211+
// upgrade a load balancer may route partially to the old server, and that
212+
// would make new asset paths get cached as 404s and not load even once the
213+
// new server was in place. To combat that, only cache if we have the file.
214+
ifh.exists(reqFile)&&ShouldCacheFile(reqFile) {
215+
rw.Header().Add("Cache-Control","public, max-age=31536000, immutable")
216+
}
217+
// If the asset does not exist, this will return a 404.
218+
h.handler.ServeHTTP(rw,r)
219+
return
208220
// If the original file path exists we serve it.
209221
caseh.exists(reqFile):
210222
ifShouldCacheFile(reqFile) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp