Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: store HTTP last modified date from response header #2724

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

zl4bv
Copy link
Contributor

@zl4bv zl4bv commented Aug 8, 2024

This addresses a scenario where a server providing a feed responds with a Last-Modified header that is derived from a file modification time. A static site generator, for example, may re-create a feed file without making changes to the file contents - in particular the pubDate for any feed items. Now the mtime and Last-Modified header have a date that is newer than any pubDate elements.

If News sends a request with a If-Modified-Since header based on the older pubDate then the server will respond with 200 and send the entire feed file contents even though the feed has not logically changed. To minimise server bandwidth, ideally News sends a last modified date based on the Last-Modified header it received during the last fetch so that the server can respond with 304.

Summary

  • When an HTTP Last-Modified header is present store the value from the header.

Checklist

@Grotax
Copy link
Member

Grotax commented Aug 17, 2024

Hey,

I think this:

if ($feed->getLastModified() instanceof DateTime) {
$newFeed->setHttpLastModified($feed->getLastModified()->format(DateTime::RSS));
}
$newFeed->setAdded($this->time->getTime());

can be removed then otherwise it would set the date first and then the new logic would overwrite the field again.

@Grotax Grotax requested a review from SMillerDev August 26, 2024 08:26
@Grotax Grotax force-pushed the fix/http-last-modified-response branch 2 times, most recently from c765583 to 3fad2bd Compare September 21, 2024 05:57
@Grotax Grotax enabled auto-merge (rebase) September 21, 2024 05:57
@zl4bv
Copy link
Contributor Author

zl4bv commented Sep 24, 2024

Apologies for the delayed response. Been on vacation and still catching up on things.

Appreciate your feedback that that line isn't needed.

@Grotax Grotax disabled auto-merge September 24, 2024 08:18
zl4bv and others added 3 commits September 29, 2024 10:47
Signed-off-by: Ben Vidulich <ben@vidulich.nz>
Signed-off-by: Ben Vidulich <ben@vidulich.nz>
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
@Grotax Grotax force-pushed the fix/http-last-modified-response branch from e5a08d5 to d9845fe Compare September 29, 2024 08:47
@Grotax Grotax enabled auto-merge (rebase) September 29, 2024 08:47
@Grotax Grotax disabled auto-merge September 29, 2024 09:08
@Grotax Grotax merged commit 008c189 into nextcloud:master Sep 29, 2024
14 of 25 checks passed
@zl4bv zl4bv deleted the fix/http-last-modified-response branch September 29, 2024 12:52
Grotax added a commit that referenced this pull request Oct 3, 2024
Fixed
- Use updated user agent when fetching feeds and favicons (#2788)
- Allow feed title to be null in DB. (#2745)
- Store HTTP last modified date from response header (#2724)
- Admin settings could not be saved (#2533)

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
Grotax added a commit that referenced this pull request Oct 3, 2024
Fixed
- Use updated user agent when fetching feeds and favicons (#2788)
- Allow feed title to be null in DB. (#2745)
- Store HTTP last modified date from response header (#2724)
- Admin settings could not be saved (#2533)

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
Grotax added a commit that referenced this pull request Oct 3, 2024
Fixed
- Use updated user agent when fetching feeds and favicons (#2788)
- Allow feed title to be null in DB. (#2745)
- Store HTTP last modified date from response header (#2724)
- Admin settings could not be saved (#2533)

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
@Grotax Grotax mentioned this pull request Oct 3, 2024
Grotax added a commit that referenced this pull request Oct 4, 2024
Fixed
- Use updated user agent when fetching feeds and favicons (#2788)
- Allow feed title to be null in DB. (#2745)
- Store HTTP last modified date from response header (#2724)
- Admin settings could not be saved (#2533)

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
@plum-pan
Copy link

Confirming this issue is fixed, user was requesting feeds from my apache server and was previously pulling a new feed every request, now they're getting 304 unless there's something new to get. 🎉

They were on alpha08 before, now alpha11. Had to get in touch to find out the old version, very glad the new one updates the user-agent too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants