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/
This commit is contained in:
Scott Leggett 2024-07-02 23:12:53 +08:00 committed by Frédéric Guillot
parent c787bb5b48
commit bf1c851093

View file

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