fix: redo the whole caching functionality to make it really 420 blaze it fast #3
@@ -66,7 +66,7 @@ var rootCmd = &cobra.Command{
|
||||
)
|
||||
|
||||
logger.Logger.Info().
|
||||
Msg("starting SteamCache2 on port 80")
|
||||
Msg("SteamCache2 listening on port 80")
|
||||
|
||||
sc.Run()
|
||||
|
||||
|
||||
@@ -179,6 +179,8 @@ func (sc *SteamCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(r.URL.String(), "/depot/") {
|
||||
|
||||
tstart := time.Now()
|
||||
|
||||
cacheKey := strings.ReplaceAll(r.URL.String()[1:], "\\", "/") // replace all backslashes with forward slashes shouldn't be necessary but just in case
|
||||
@@ -306,4 +308,22 @@ func (sc *SteamCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
Int64("size", int64(len(body))).
|
||||
Dur("duration", time.Since(tstart)).
|
||||
Msg("request")
|
||||
return
|
||||
}
|
||||
|
||||
if r.URL.Path == "/favicon.ico" {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
if r.URL.Path == "/robots.txt" {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("User-agent: *\nDisallow: /\n"))
|
||||
return
|
||||
}
|
||||
|
||||
requestsTotal.WithLabelValues(r.Method, "404").Inc()
|
||||
logger.Logger.Warn().Str("url", r.URL.String()).Msg("Not found")
|
||||
http.Error(w, "Not found", http.StatusNotFound)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user