From 600547342a6c8111292d54e5c5a1e086847148bb Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sun, 1 Aug 2021 13:46:42 +0200 Subject: [PATCH] implemented If-None-Match header on file get --- internal/s3Broswer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/s3Broswer.go b/internal/s3Broswer.go index b0c7271..56a81fe 100644 --- a/internal/s3Broswer.go +++ b/internal/s3Broswer.go @@ -71,6 +71,12 @@ func initHttp(schema graphql.Schema, s3Client *minio.Client, loaderMap map[strin return } + reqEtag := r.Header.Get("If-None-Match") + if reqEtag == objInfo.ETag { + rw.WriteHeader(304) + return + } + obj, err := s3Client.GetObject(context.Background(), bucketName, id, minio.GetObjectOptions{}) if err != nil { @@ -78,7 +84,7 @@ func initHttp(schema graphql.Schema, s3Client *minio.Client, loaderMap map[strin return } - rw.Header().Set("Cache-Control", "no-store") + rw.Header().Set("Cache-Control", "must-revalidate") rw.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filepath.Base((objInfo.Key)))) rw.Header().Set("Content-Type", objInfo.ContentType) rw.Header().Set("ETag", objInfo.ETag)