mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
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.
This commit is contained in:
@@ -312,8 +312,10 @@ func (s3 *S3Backend) GetManifest(ctx context.Context, name string) (*Manifest, e
|
||||
if err != nil {
|
||||
if errResp := minio.ToErrorResponse(err); errResp.Code == "NoSuchKey" {
|
||||
err = fmt.Errorf("%w: %s", errNotFound, errResp.Key)
|
||||
return &CachedManifest{nil, 1, err}, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
return &CachedManifest{nil, 1, err}, nil
|
||||
} else {
|
||||
return &CachedManifest{manifest, size, err}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user