Explorar o código

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 hai 1 ano
pai
achega
bf1c851093
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  1. 4 4
      internal/reader/fetcher/response_handler.go

+ 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