Thursday, April 02, 2026

ftp and Last-Modified:

I see some strange behaviour when trying to use ftp -T to conditionally
download a file if it has changed. This is ftp from 7.8.

Here is an example to illustrate it, beginning with the non-working
version:

Header send by server:
% curl -ILs https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since | grep -i last-modified
last-modified: Thu, 02 Apr 2026 01:11:07 GMT

Timestamp after downloading:
% ftp -V https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since >/dev/null; stat -x If-Modified-Since| grep Modify
Modify: Thu Apr 2 03:11:07 2026

Using ftp -T when fetching again:
% ftp -T https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since
Trying 151.101.37.91...
Requesting https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since
100% |*******************************************************| 201 KB 00:00
206655 bytes received in 0.02 seconds (6.96 MB/s)
% ftp -T https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since
Trying 151.101.37.91...
Requesting https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since
100% |*******************************************************| 201 KB 00:00
206655 bytes received in 0.02 seconds (7.27 MB/s)

Here are the exact same commands with httpd as server which works as
expected:
% curl -ILs https://rkta.de/index.html | grep -i last-modified
Last-Modified: Fri, 26 Dec 2025 09:36:01 UTC
% ftp -V https://rkta.de/index.html >/dev/null; stat -x index.html| grep Modify
Modify: Fri Dec 26 10:36:01 2025
% ftp -T https://rkta.de/index.html
Trying 46.23.93.159...
Requesting https://rkta.de/index.html
ftp: File is not modified on the server

What am I doing wrong here?

No comments:

Post a Comment