cache: Key by depot path across CDN host aliases
This commit is contained in:
@@ -279,9 +279,12 @@ func (sc *SteamCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Check if this is a request from a supported service
|
||||
if service, isSupported := sc.detectService(r); isSupported {
|
||||
// trim the query parameters from the URL path
|
||||
// this is necessary because the cache key should not include query parameters
|
||||
urlPath := strings.SplitN(r.URL.String(), "?", 2)[0] // trim query for cache key (SplitN makes intent explicit vs Cut + ignored bool)
|
||||
// Cache key is the path only, never the Host: Steam rotates CDN hostnames
|
||||
// for the same depot object, so different Host headers (or absolute-form
|
||||
// request targets) for the same path must share one cache entry. r.URL.Path
|
||||
// is the decoded path (query is never part of it); validateURLPath checks
|
||||
// this decoded form and url.JoinPath re-escapes it for the upstream join.
|
||||
urlPath := r.URL.Path
|
||||
|
||||
// Validate URL path for security
|
||||
if err := validateURLPath(urlPath); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user