4
0
Эх сурвалжийг харах

fetcher: use ETag as a stronger validator than Last-Modified

As per the MDN article on HTTP caching:

  During cache revalidation, if both If-Modified-Since and If-None-Match
  are present, then If-None-Match takes precedence for the validator.

  https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching

Previously Miniflux would consider a resource unmodified if the
Last-Modified header had not changed, even if the ETag had changed.

With this commit, Miniflux will consider a resource modified if the ETag
header has changed, even if Last-Modified has not.

This fixes Bug 1 in https://rachelbythebay.com/w/2024/06/11/fsr/
Scott Leggett 1 жил өмнө
parent
commit
bf1c851093

+ 4 - 4
internal/reader/fetcher/response_handler.go

@@ -56,12 +56,12 @@ func (r *ResponseHandler) IsModified(lastEtagValue, lastModifiedValue string) bo
 		return false
 	}
 
-	if r.ETag() != "" && r.ETag() == lastEtagValue {
-		return false
+	if r.ETag() != "" {
+		return r.ETag() != lastEtagValue
 	}
 
-	if r.LastModified() != "" && r.LastModified() == lastModifiedValue {
-		return false
+	if r.LastModified() != "" {
+		return r.LastModified() != lastModifiedValue
 	}
 
 	return true