Skip to content
Latchkey

wget -N: Only Download Changed Files

wget -N compares the local file’s timestamp and size with the server’s and re-downloads only when the remote is newer.

For caches and mirrors that run repeatedly, -N avoids re-fetching files that have not changed, which saves bandwidth and time.

What it does

wget -N (--timestamping) checks the remote Last-Modified header and content length against the local file. If the local file is at least as new and the same size, wget skips the download; otherwise it re-fetches. It needs a writable existing file and a server that sends Last-Modified.

Common usage

Terminal
wget -N https://example.com/tools/installer.sh
# timestamping across a mirror
wget --mirror -np https://example.com/artifacts/

Options

FlagWhat it does
-N / --timestampingOnly download if the remote file is newer
--no-if-modified-sinceUse a HEAD plus comparison instead of If-Modified-Since
-P <dir>Directory to compare and save into
-O <file>Note: -O conflicts with -N (timestamping needs the real name)

In CI

Pair -N with a cache that persists the downloaded file between runs, so the second run skips unchanged downloads. It only helps if the file survives across jobs; on a clean runner there is nothing to compare and -N always downloads.

Common errors in CI

Last-modified header missing -- time-stamps turned off means the server did not send Last-Modified, so wget cannot compare and downloads every time. Combining -N with -O triggers "Cannot specify both -N and -O" or undefined behavior; let wget keep the real filename when timestamping.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →