mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-23 23:30:25 +08:00
清理缓存时也清理HEAD缓存
This commit is contained in:
@@ -351,12 +351,11 @@ func (this *APIStream) handlePurgeCache(message *pb.NodeStreamMessage) error {
|
|||||||
if msg.Type == "file" {
|
if msg.Type == "file" {
|
||||||
var keys = msg.Keys
|
var keys = msg.Keys
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
keys = append(keys, key+webpCacheSuffix)
|
keys = append(keys, key+webpCacheSuffix, key+cacheMethodSuffix+"HEAD")
|
||||||
// TODO 根据实际缓存的内容进行组合
|
// TODO 根据实际缓存的内容进行组合
|
||||||
for _, encoding := range compressions.AllEncodings() {
|
for _, encoding := range compressions.AllEncodings() {
|
||||||
keys = append(keys, key+compressionCacheSuffix+encoding)
|
keys = append(keys, key+compressionCacheSuffix+encoding)
|
||||||
keys = append(keys, key+webpCacheSuffix+compressionCacheSuffix+encoding)
|
keys = append(keys, key+webpCacheSuffix+compressionCacheSuffix+encoding)
|
||||||
keys = append(keys, key+cacheMethodSuffix+"HEAD")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.Keys = keys
|
msg.Keys = keys
|
||||||
|
|||||||
@@ -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 {
|
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"
|
this.varMapping["cache.status"] = "PURGE"
|
||||||
|
|
||||||
var subKeys = []string{key}
|
var subKeys = []string{key, key + cacheMethodSuffix + "HEAD"}
|
||||||
// TODO 根据实际缓存的内容进行组合
|
// TODO 根据实际缓存的内容进行组合
|
||||||
for _, encoding := range compressions.AllEncodings() {
|
for _, encoding := range compressions.AllEncodings() {
|
||||||
subKeys = append(subKeys, key+compressionCacheSuffix+encoding)
|
subKeys = append(subKeys, key+compressionCacheSuffix+encoding)
|
||||||
subKeys = append(subKeys, key+webpCacheSuffix+compressionCacheSuffix+encoding)
|
subKeys = append(subKeys, key+webpCacheSuffix+compressionCacheSuffix+encoding)
|
||||||
subKeys = append(subKeys, key+cacheMethodSuffix+"HEAD")
|
|
||||||
}
|
}
|
||||||
for _, subKey := range subKeys {
|
for _, subKey := range subKeys {
|
||||||
err := storage.Delete(subKey)
|
err := storage.Delete(subKey)
|
||||||
|
|||||||
@@ -265,10 +265,6 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) {
|
|||||||
|
|
||||||
var expiredAt = utils.UnixTime() + life
|
var expiredAt = utils.UnixTime() + life
|
||||||
var cacheKey = this.req.cacheKey
|
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)
|
cacheWriter, err := storage.OpenWriter(cacheKey, expiredAt, this.StatusCode(), size, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !caches.CanIgnoreErr(err) {
|
if !caches.CanIgnoreErr(err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user