Skip to content

Commit

Permalink
fetcher: use ETag as a stronger validator than Last-Modified
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
smlx committed Jul 2, 2024
1 parent fa15e7e commit 865ddba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/reader/fetcher/response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 865ddba

Please sign in to comment.