dart-archive / shelf_static

archived repo
https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_static
BSD 3-Clause "New" or "Revised" License
24 stars 24 forks source link

Stale content is served on windows when browser sents IfModifiedSince header #37

Closed DanTup closed 4 years ago

DanTup commented 4 years ago

On Windows, updating the file on disk and reloading in the browser returns a "Not modified" header, so stale content is shown.

I believe the cause is the user of stat.changed here:

https://github.com/dart-lang/shelf_static/blob/fb4506e7485e4ff7a3b97dfae3f6e02215e64782/lib/src/static_handler.dart#L185

The comment on stat.changed says:

  /**
   * The time of the last change to the data or metadata of the file system
   * object.
   *
   * On Windows platforms, this is instead the file creation time.
   */

I'm not sure why it has this behaviour on Windows, but there's another field called modified that doesn't contain this text, so perhaps that one should be used instead?

DanTup commented 4 years ago

Weirdly, in the Dart code there's an enum that has this "changed" value:

https://github.com/dart-lang/sdk/commit/fb8471244f84f115995c9de68b23099c8a1251fc#diff-7a1f497563e66f6bd60c0f1586580ca5R29

But it says it should match an enum in file.h. However that enum seems to call it "created":

https://github.com/dart-lang/sdk/blob/202e32afebce3226879c0ab9920ced365847d79d/runtime/bin/file.h#L90

This seems a bit confusing!