diff options
author | Eric Bailey <git@esb.lol> | 2024-10-04 09:33:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-04 09:33:32 -0500 |
commit | 54ca8165360b886d8e7272a0e70ccf3bc7a11e2a (patch) | |
tree | 86289b0d2cfb18359050bd7f26e6a2e047ec3473 /bskyweb | |
parent | 48241cb2b6cec2b513daa86303f9e6ee4fcacd10 (diff) | |
download | voidsky-54ca8165360b886d8e7272a0e70ccf3bc7a11e2a.tar.zst |
Update built asset caching (#5601)
Diffstat (limited to 'bskyweb')
-rw-r--r-- | bskyweb/cmd/bskyweb/server.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 54c5f075a..ea102802e 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -204,14 +204,8 @@ func serve(cctx *cli.Context) error { path := c.Request().URL.Path maxAge := 1 * (60 * 60) // default is 1 hour - // Cache javascript and images files for 1 week, which works because - // they're always versioned (e.g. /static/js/main.64c14927.js) - if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/images/") || strings.HasPrefix(path, "/static/media/") { - maxAge = 7 * (60 * 60 * 24) // 1 week - } - - // fonts can be cached for a year - if strings.HasSuffix(path, ".otf") { + // all assets in /static/js, /static/css, /static/media are content-hashed and can be cached for a long time + if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/css/") || strings.HasPrefix(path, "/static/media/") { maxAge = 365 * (60 * 60 * 24) // 1 year } |