Skip to content
Merged
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
8 changes: 2 additions & 6 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ func esmRouter(db Database, buildStorage storage.Storage, logger *log.Logger) re
case output := <-ch:
if output.err != nil {
if output.err.Error() == "types not found" {
ctx.SetHeader("Cache-Control", ccImmutable)
ctx.SetHeader("Cache-Control", fmt.Sprintf("public, max-age=%d", config.NpmQueryCacheTTL))
return rex.Status(404, "Types Not Found")
}
return rex.Status(500, "Failed to build types: "+output.err.Error())
Expand Down Expand Up @@ -1583,11 +1583,7 @@ func esmRouter(db Database, buildStorage storage.Storage, logger *log.Logger) re
if output.err != nil {
msg := output.err.Error()
if msg == "could not resolve build entry" || strings.HasSuffix(msg, " not found") || strings.Contains(msg, "is not exported from package") || strings.Contains(msg, "no such file or directory") {
if strings.HasPrefix(msg, "version ") && strings.HasSuffix(msg, " not found") {
ctx.SetHeader("Cache-Control", fmt.Sprintf("public, max-age=%d", config.NpmQueryCacheTTL))
} else {
ctx.SetHeader("Cache-Control", ccImmutable)
}
ctx.SetHeader("Cache-Control", fmt.Sprintf("public, max-age=%d", config.NpmQueryCacheTTL))
return rex.Status(404, msg)
}
return rex.Status(500, msg)
Expand Down
Loading