fork of whitequark.org/git-pages with mods for tangled

Only cache NotFound errors from S3 backend, rather than any errors.

We need to cache NotFound responses to avoid hitting the backend
whenever there's a flurry of requests for the same invalid domain.
But caching any kind of error, including context cancellation, results
in poisoning the cache with that error, e.g. if the domain exists but
the client that requested it first did not wait for the response.

Changed files
+3 -1
src
+3 -1
src/backend_s3.go
··· 312 312 if err != nil { 313 313 if errResp := minio.ToErrorResponse(err); errResp.Code == "NoSuchKey" { 314 314 err = fmt.Errorf("%w: %s", errNotFound, errResp.Key) 315 + return &CachedManifest{nil, 1, err}, nil 316 + } else { 317 + return nil, err 315 318 } 316 - return &CachedManifest{nil, 1, err}, nil 317 319 } else { 318 320 return &CachedManifest{manifest, size, err}, nil 319 321 }