What is the Wget Timestamping Feature?
The wget timestamping feature allows the command-line
utility to automatically check the modification date of a remote file
before downloading it. By comparing the remote file’s timestamp with the
local file’s timestamp, wget ensures that it only downloads
the file if the remote version is newer. This prevents redundant
downloads, saving both network bandwidth and time when mirroring
websites or maintaining backups.
How Wget Timestamping Works
When you use the timestamping feature, wget sends a
specific HTTP or FTP request to the server to check the file’s
properties without downloading the entire payload.
- The Check:
wgetlooks at the local file size and its last-modified timestamp. It then requests theLast-Modifiedheader from the remote server. - The Decision: If the remote file has a newer
timestamp than the local copy (or if the file sizes differ),
wgetproceeds with the download and updates the local file’s modification time to match the server. - The Bypass: If the remote file is older or
identical to the local copy,
wgetskips the download entirely, reporting that the local file is already up to date.
Key Benefits of Using Timestamping
Implementing timestamping is highly efficient for automated scripts, cron jobs, and large-scale data synchronization.
- Bandwidth Conservation: By avoiding the retrieval of unchanged files, you significantly reduce data usage for both your machine and the hosting server.
- Time Efficiency: Skipping large, unmodified datasets speeds up replication and backup routines.
- Automation-Friendly: It allows scripts to run repeatedly (e.g., daily mirrors) while ensuring that only updated content is transferred.
How to Trigger Timestamping in the Command Line
To enable this feature, you use the -N (or
--timestamping) option in your command.
wget -N https://example.com/data-file.csvIf you run this command a second time, and the
data-file.csv on the server has not changed,
wget will acknowledge the local file is current and exit
without downloading it again.