AI translation
TL;DR
Older versions of Nextcloud News (before 25.0.0) send the <lastBuildDate> from the feed as If-Modified-Since instead of the Last-Modified from the server. If build and upload are even a few seconds apart, the server delivers the full feed every time, and with the full-text option every article on top. Current versions have fixed this behaviour, but not every operator runs them. The server-side fix: set the file date of the feed to its <lastBuildDate>.
A personal foreword for one particular user
Dear reader,
if you read my blog with a Nextcloud News that introduces itself to web servers as version 1.0, this article is about you!
Best regards Jörg
A foreword for everyone else
This is a report on how a small thing can have surprisingly large consequences. A bug-hunting story and, for other blog operators, perhaps a helpful text on how to catch this problem on the server side.
Background
Every now and then I really like to take a look at my log files. I let them scroll past with tail -f. With my blog, that’s mostly because the log shows you that someone is actually accessing the things you write. As much as you write for yourself, it’s still nice to see that you’re being read.
Of course, the initial joy over the access numbers cools down quite quickly once you realise that you haven’t been shouting into the void, but at legions of bots instead.
Of course, I also have a script that analyses my log files. I don’t use a standard tool for this, but something specific to my blog. It can do tricks such as checking whether a referrer actually refers. It happens surprisingly often in my logs that requests supposedly come from pages that don’t link here at all. Since my pages are statically generated, I can tell that precisely.
At some point I noticed that I had a regular visitor. Very regular. So regular that at first I started to worry seriously about my website whenever I got fewer than 400 requests a day from a particular IP, assuming that something on my end was broken. After that, I started worrying about whoever was behind these requests: if you work in a bakery and a customer comes by every day for a cup of coffee and a Franzbrötchen, you naturally wonder what’s going on when they stop coming. That happened to me once. No, I wasn’t dead or ill. Just on a diet.
In my case, this regular visitor was a Nextcloud News installation. Every 15 minutes. Like clockwork. The installation fetches the blog’s feed every 15 minutes. There’s nothing disreputable about that in itself. That’s simply what feed readers do. What came next was strange. It was also what caught my eye in my log analysis: the six most recent articles (my feed contained six articles) never had fewer than a certain number of requests. It quickly turned out that after fetching the feed, every article listed in the feed was fetched in full. On my blog, that makes no sense, because the full article is already in my feed. Nowadays even twice.
And it did this not just once, but every 15 minutes. Over the course of a day, that added up to about 24 MB for the same posts.
Now any normal person would think: 24 MB? Who cares. More data falls out of my trouser pocket when I walk. The server doesn’t notice. I waste more bandwidth on random crawlers that never give anything back.
But do you know the feeling when you notice something, have no explanation and put it aside for the time being because you have too much to do? And then that itch keeps coming back whenever you look at the log analysis and this view stares back at you? By the way, these were the requests counted on a single day.
| Rule | Requests |
|---|---|
| Runaway NextCloud instance (NextCloud-News/1.0) | 1,151 |
At some point I’d had enough and went looking. Along the way I found a number of bugs, but none of them managed to calm down the runaway Nextcloud instance.
Whodunit?
The culprit identified itself as NextCloud-News/1.0. And it really was only this one culprit. Even younger siblings such as NextCloud-News/28.x or 29.x behaved differently. They also fetched the feed every 15 minutes (or at some other regular interval). But since the feed file didn’t change that often, they only got a short “304 Not Modified” back, along with a request to get lost. And they got lost. For 15 minutes. In between, there were no further requests for the posts.
But this system was different: all year long, there were these regular requests for the six newest posts. In December, the system even changed its IP address. Still: the same rhythm, the same requests, the same instance. Just a different IP.
At first, I solved the problem by filtering it out of the log analysis. What I don’t know can’t hurt me. But of course, that only hides the “problem”.
Looking at the headers
Apache’s normal access log tells you what was asked and what was answered. But only in a very condensed form. It can’t answer the question of what exactly the client asked. After all, the question doesn’t just consist of GET /feed.xml HTTP/2.0, but also of a number of other request headers. And those aren’t in the log.
So I added something to my configuration that logs these request headers. But only for this one user identifying itself as NextCloud-News/1.0, and without the IP address, so that in all likelihood no personal data (PII) would be collected – the IP was irrelevant to the question anyway. In Apache, you can write such conditional logs by setting an environment variable under a condition and then configuring a CustomLog that is only active when this variable is set:
SetEnvIf User-Agent "^NextCloud-News/1\.0$" nc_headers
CustomLog /var/log/apache2/c0t0d0s0.org-nextcloud.log "%t %{local}p \"%r\" %>s %B \"Host: %{Host}i\" \"Accept-Encoding: %{Accept-Encoding}i\" \"If-Modified-Since: %{If-Modified-Since}i\"" env=nc_headers
Then I waited for the instance (it was at most 15 minutes, after all) and saw the following result (heavily shortened):
"GET /feed.xml HTTP/1.1" 301 Host: c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 04:26:30 GMT
"GET /feed.xml HTTP/1.1" 200 Host: www.c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 04:26:30 GMT
"GET /icon-192.png HTTP/1.1" 304 If-Modified-Since: Fri, 04 Dec 2026 04:38:50 GMT
"GET /index.php?/feeds/index.rss2" 301 Host: c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 04:26:30 GMT
"GET /feed.xml HTTP/1.1" 200 Host: www.c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 04:26:30 GMT
"GET /blog/petergabriel-io.html?from=feed HTTP/2.0" 200 Accept-Encoding: - If-Modified-Since: -
"GET /blog/bunkerwald.html?from=feed HTTP/2.0" 200 Accept-Encoding: - If-Modified-Since: -
... four more posts ...
If you look closely, you’ll find two clients in this excerpt.
Client 1: The feed
The first client fetches the feed. Twice, by the way: the installation has the blog subscribed under two old addresses. One is c0t0d0s0.org/feed.xml – without the www and therefore not via the canonical address. The other is index.php?/feeds/index.rss2, a leftover from the days when this blog ran on Serendipity. That’s not a problem, though, because both get redirected to the current feed every time.
When I first saw this strange pattern, I thought a maximally “dumb” client was simply fetching the complete feed every time without checking whether a new version was available at all. But that’s not the case. The client is polite. It sends an If-Modified-Since header. This works roughly like this: in its HTTP response for the feed, the server includes a Last-Modified time, and the client has to remember it and send it along with the next request: “I’ve got the version from 12:59 today – got anything new?” If the server has nothing new, it just answers with a 304 and no further content. If there is something newer, it answers with a 200 and sends the content along. Besides the time, there’s also the ETag mechanism, but it doesn’t work on my server because the server compresses its responses.1
And that piqued my curiosity. The client is actually doing the right thing, but the right thing doesn’t come out of it. Why does the server hand out the entire feed every time? That really took quite a bit of puzzling.
The answer is actually quite simple. The client asks for the wrong time! Take a look at the If-Modified-Since: it asks for 04:26:30 GMT. From the server’s point of view, however, the situation looks like this:
| Source | Date |
|---|---|
<lastBuildDate> in the feed |
Fri, 04 Dec 2026 05:26:30 +0100 – i.e. 04:26:30 GMT |
Last-Modified from the server |
Fri, 04 Dec 2026 04:26:44 GMT |
So the client doesn’t remember the server’s Last-Modified time, but uses whatever is between <lastBuildDate> and </lastBuildDate>. I can easily imagine the reasoning behind this: the feed already says when it’s from. Data that’s lying around anyway.
However, in my deployment process, a few seconds can easily pass between generating the feed and transferring it. Jekyll writes the date into the feed at the moment the feed is generated. A few steps later, at the end of the build pipeline, the file is uploaded to the web server using rsync. And the time attached to the file is the basis for the Last-Modified that the web server delivers. For this build, the difference between the two timestamps was 14 seconds.
If the client asked with the last Last-Modified, Apache would check the file: “Is it newer than Fri, 04 Dec 2026 04:26:44 GMT?” Since the file at hand was created at exactly that moment, the server answers the client with “Nope!”, i.e. with a 304 “Nothing new, get lost”. Because of the wrong date on the client side, however, Apache checks: “Is it newer than Fri, 04 Dec 2026 04:26:30 GMT?” And Apache has to answer: “Yes, I have a file from Fri, 04 Dec 2026 04:26:44 GMT” and delivers the entire feed. This can never work. A difference of a single second would have been enough.
Of course, the whole thing is a bug in the client. And current versions have fixed this behaviour. However, it’s an inconvenient truth that not every operator keeps their environment up to date all the time. But you can do something about it on the server side by meeting the client halfway.
The fix on my side
To fix the problem on the server side, you have to set the date of the file to the value in <lastBuildDate></lastBuildDate>.
This can be done with a short script that runs over all .xml files containing feeds. In my setup, it’s part of the pipeline on every build. This is the crucial part (the script I actually use is longer because it also handles error cases):
const m = fs.readFileSync(file, 'utf8').match(/<lastBuildDate>([^<]+)<\/lastBuildDate>/);
const time = new Date(m[1].trim());
fs.utimesSync(file, time, time);
However, there was a small catch. A few days earlier, during my search, I had already noticed another problem: my build process is designed to always run on a fresh checkout in a Gitea runner. So every file had the timestamp of the checkout. But a website consists not only of the generated HTML files, but also of lots of assets such as images, fonts and PDFs. If I started rsync with -t, every single file would get the date of the checkout, even if nothing had changed. So my website hadn’t been particularly 304-friendly before.
That in turn would have meant that every browser and every crawler would have downloaded everything again after every deploy. The If-Modified-Since mechanism described above would then have reported “changed” for every file, with a 200 and the full content. Clients would only have got a 304 if they had visited the website several times between two builds. But since the website is partly built and uploaded automatically by a Gitea workflow, that would have been rather unlikely.
Without -t, unchanged files keep their date – provided rsync uses --checksum or --size-only to check whether they have changed. Then rsync simply leaves them alone. For the changed files, however, the date on the target server after the transfer is the upload date, i.e. neither the build date nor the date in the XML file. For almost all files on the web server, it is completely irrelevant whether the date is accurate to the second. Just not for the XML files of the RSS feeds – because of the quirk of this one client.
This problem is worked around with a second rsync whose only job is to transfer the XML files to the web server, this time with -t. The files already have the right content; it’s only about the timestamp. Since these files only live in the top-level directory in my setup, I was able to implement it like this:
rsync -rtz --checksum --omit-dir-times --include='/*.xml' --exclude='*' ...
And then it works as expected:
"GET /feed.xml HTTP/1.1" 301 Host: c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 05:00:58 GMT
"GET /feed.xml HTTP/1.1" 304 Host: www.c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 05:00:58 GMT
"GET /index.php?/feeds/index.rss2" 301 Host: c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 05:00:58 GMT
"GET /feed.xml HTTP/1.1" 304 Host: www.c0t0d0s0.org If-Modified-Since: Fri, 04 Dec 2026 05:00:58 GMT
The server can now properly answer with a 304. I couldn’t get rid of the 301s; that can really only be done on the client side. But that’s small potatoes compared to the previous situation.
Client 2: The posts
Then there’s the second client: the post scraper. It fetches the posts and seems to work completely differently: HTTP/2 instead of 1.1, it accepts everything and doesn’t ask for compression. Nor does it ask whether anything has changed. The consequence: every post is downloaded again and again, in full and in all its uncompressed glory.
I’d say this looks like the “Full Text” option of Nextcloud News. You need this option when the feed only contains teasers. With it, the full text is downloaded from the page. And, as already mentioned, apparently every time the server delivers the feed anew.
If the first client gets a 304, the second client apparently refrains from downloading the posts again. That is also the behaviour I’ve been seeing in my log files since this workaround.
Conclusion
With this change on my side, I was able to work around the client’s bug on the server side. Nevertheless, I’d ask you to switch the feeds to https://www.c0t0d0s0.org/feed.xml and, while you’re at it, turn off the “Full Text” feature. As mentioned, the feed contains the full articles.
You could also update your Nextcloud News app: newer versions (since version 25.0.0) behave correctly here and don’t have this problem. I see that again and again in my log file as well. Since I suspect that my blog isn’t the only one where the time in the feed and the time on the file can differ, this miraculous multiplication of traffic might be happening with many other subscribed blogs too.
Postscript
After all this troubleshooting, I finally had the right search terms to find the problem: fix: store HTTP last modified date from response header (#2724)
-
Apache appends “-br” to the ETag when it compresses a response with Brotli, but doesn’t recognise this suffix when a client sends the ETag back. So every ETag-based “has this changed?” was answered with the full file. The server now only sends
Last-Modifiedfor compressed files. More about this in the technical review of the year. ↩
Found a mistake, or is something outdated? Questions about the text? Ideas? Get in touch with the author