Skip to content

Commit

Permalink
Update built asset caching (#5601)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Oct 4, 2024
1 parent 48241cb commit 54ca816
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions bskyweb/cmd/bskyweb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 54ca816

Please sign in to comment.