Option to preserve timestamps on downloaded files #6

hickford opened this Issue Dec 27, 2011 · 4 comments


None yet

2 participants


Hi. It would be useful to have an option to preserve the timestamps when downloaded files are saved to this. This happens to be default behaviour of wget and other download software http://www.gnu.org/software/wget/manual/wget.html

By default, when a file is downloaded, it's timestamps are set to match those from the remote file. This allows the use of ‘--timestamping’ on subsequent invocations of wget. However, it is sometimes useful to base the local file's timestamp on when it was actually downloaded; for that purpose, the ‘--no-use-server-timestamps’ option has been provided.

Modern web browsers don't preserve timestamps:


I'll take a stab at figuring out which of the fs-related call is required in order to implement this. Any suggestion is welcome.


Hi Stefan. Thanks for your interest. Here's how I did it in my script:

httpget = require('http-get')
fs = require('fs')   
await httpget.get({url:url},destination,defer(err,result))
timestamp = new Date(result.headers['last-modified'])
await fs.utimes(destination,timestamp,timestamp,defer())

Thinking about it, I concluded that preserving timestamps has a niche use case (viz. mirroring) and while a vital feature to wget isn't necessary in a library since one can take the timestamp from the response header as above. I am closing the issue. Of course, do as you like.

@hickford hickford closed this Dec 30, 2011

The funny thing is that I wrote http-get for mirroring a large number of files. The database uses versioning though, therefore the timestamping was never an issue, but it is still a nice thing to have in the toolkit.

@SaltwaterC SaltwaterC reopened this Dec 31, 2011

Closed by releasing v0.4: if the Last-Modified header is set, then for the file downloads it keeps the timestamp as the mtime value.

@SaltwaterC SaltwaterC closed this May 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment