diff options
| author | Jamal Carvalho <jamal@golang.org> | 2022-09-27 19:18:35 +0000 |
|---|---|---|
| committer | Jamal Carvalho <jamal@golang.org> | 2022-09-28 15:06:13 +0000 |
| commit | 486923138cca845d1a4d97a44d7bfda3bdf16bb8 (patch) | |
| tree | 2154b9994bedc2c6e3b340ff350eb82352c5aa9c /internal | |
| parent | ffdb1173e965e6a57ab6c2f9b16509ef139313ea (diff) | |
| download | go-x-pkgsite-486923138cca845d1a4d97a44d7bfda3bdf16bb8.tar.xz | |
internal/frontend: add vuln pages to redis cache
Change-Id: I1d4126a7f040c8926ab573a915d7fc1eac61619d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/435376
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/frontend/server.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/frontend/server.go b/internal/frontend/server.go index 8d358bf9..901d4921 100644 --- a/internal/frontend/server.go +++ b/internal/frontend/server.go @@ -129,10 +129,12 @@ func (s *Server) Install(handle func(string, http.Handler), redisClient *redis.C detailHandler http.Handler = s.errorHandler(s.serveDetails) fetchHandler http.Handler = s.errorHandler(s.serveFetch) searchHandler http.Handler = s.errorHandler(s.serveSearch) + vulnHandler http.Handler = s.errorHandler(s.serveVuln) ) if redisClient != nil { detailHandler = middleware.Cache("details", redisClient, detailsTTL, authValues)(detailHandler) searchHandler = middleware.Cache("search", redisClient, searchTTL, authValues)(searchHandler) + vulnHandler = middleware.Cache("vuln", redisClient, vulnTTL, authValues)(vulnHandler) } // Each AppEngine instance is created in response to a start request, which // is an empty HTTP GET request to /_ah/start when scaling is set to manual @@ -171,7 +173,7 @@ func (s *Server) Install(handle func(string, http.Handler), redisClient *redis.C })) handle("/golang.org/x", s.staticPageHandler("subrepo", "Sub-repositories")) handle("/files/", http.StripPrefix("/files", s.fileMux)) - handle("/vuln/", http.StripPrefix("/vuln", s.errorHandler(s.serveVuln))) + handle("/vuln/", http.StripPrefix("/vuln", vulnHandler)) handle("/", detailHandler) if s.serveStats { handle("/detail-stats/", @@ -355,6 +357,11 @@ func searchTTL(r *http.Request) time.Duration { return symbolSearchTTL } +// vulnTTL assigns the cache TTL for vuln requests. +func vulnTTL(r *http.Request) time.Duration { + return defaultTTL +} + // TagRoute categorizes incoming requests to the frontend for use in // monitoring. func TagRoute(route string, r *http.Request) string { |
