How can you ensure that a fresh build on a new machine gives the same result? I can see how you can guarantee the same result in terms of file contents, but not on the file modification timestamp. e.g. if I have access to the last build it is easy to verify whether a configuration change actually resulted in modified output by comparing the file contents, meaning the last modified time can remain unchanged. When building from scratch, surely you have to assume the last modified time is the time of the build. Any thoughts?
A simple approach is to generate output to a temporary file (or memory) and only overwrite the output file if that temp file differs. When no output file exists or they differ, set the timestamp to the newest of the relevant input files.
The problem here is generating a sitemap using timestamps from output files (which are volatile) instead of the input content file. Since it tries to do incremental builds that means there are files already there that it didn't generate with the current build so nothing is known about them other than what can be gleaned from the filesystem.
So you set the output timestamp to the newest of the relevant input files as I mentioned. For example a blog post output file has as input the content file, configuration settings and templates. The output timestamp can be set to the newest of those.
Or the sitemap can use the input files to get the timestamps in which case the timestamps of files in the output directory won't matter. They would affect if-modified-since so it is preferable to have them deterministic.