From ca4889973c6db4c1d9cd4c26a77aa543e1c8ea98 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 22 Feb 2022 21:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E7=BC=93=E5=AD=98=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E6=B8=85=E7=90=86HEAD=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/api_stream.go | 3 +-- internal/nodes/http_request_cache.go | 3 +-- internal/nodes/http_writer.go | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/nodes/api_stream.go b/internal/nodes/api_stream.go index 796378e..1d23f16 100644 --- a/internal/nodes/api_stream.go +++ b/internal/nodes/api_stream.go @@ -351,12 +351,11 @@ func (this *APIStream) handlePurgeCache(message *pb.NodeStreamMessage) error { if msg.Type == "file" { var keys = msg.Keys for _, key := range keys { - keys = append(keys, key+webpCacheSuffix) + keys = append(keys, key+webpCacheSuffix, key+cacheMethodSuffix+"HEAD") // TODO 根据实际缓存的内容进行组合 for _, encoding := range compressions.AllEncodings() { keys = append(keys, key+compressionCacheSuffix+encoding) keys = append(keys, key+webpCacheSuffix+compressionCacheSuffix+encoding) - keys = append(keys, key+cacheMethodSuffix+"HEAD") } } msg.Keys = keys diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index 120fd6b..6543608 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -137,12 +137,11 @@ func (this *HTTPRequest) doCacheRead(useStale bool) (shouldStop bool) { if this.web.Cache.PurgeIsOn && strings.ToUpper(this.RawReq.Method) == "PURGE" && this.RawReq.Header.Get("X-Edge-Purge-Key") == this.web.Cache.PurgeKey { this.varMapping["cache.status"] = "PURGE" - var subKeys = []string{key} + var subKeys = []string{key, key + cacheMethodSuffix + "HEAD"} // TODO 根据实际缓存的内容进行组合 for _, encoding := range compressions.AllEncodings() { subKeys = append(subKeys, key+compressionCacheSuffix+encoding) subKeys = append(subKeys, key+webpCacheSuffix+compressionCacheSuffix+encoding) - subKeys = append(subKeys, key+cacheMethodSuffix+"HEAD") } for _, subKey := range subKeys { err := storage.Delete(subKey) diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index 0be0799..3099086 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -265,10 +265,6 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) { var expiredAt = utils.UnixTime() + life var cacheKey = this.req.cacheKey - var method = this.req.Method() - if method != http.MethodGet && method != http.MethodPost { - cacheKey += cacheMethodSuffix + this.req.Method() - } cacheWriter, err := storage.OpenWriter(cacheKey, expiredAt, this.StatusCode(), size, false) if err != nil { if !caches.CanIgnoreErr(err) {