I emailed the IETF HTTP group about my timeout header idea, and a few people said that RFC 7240's "wait" preference" does what I want. I'm not entirely convinced that this is what was intended by that spec, but it's close enough. In response, I've updated my Express middleware to support the "Prefer" header and "wait" preference.

While I was at it, I also added some tests, using Mocha and SuperTest.

Existing file
  ✓ responds immediately 
  ✓ waits for etag to change before responding if If-None-Match sent (2013ms)

Non-existing file
  ✓ responds immediately with 404 without header 
  ✓ responds with 404 if timeout expires (4006ms)
  ✓ responds with 200 if file is created before timeout expires (2003ms)
  ✓ ignores non-integer waits 
  ✓ responds with 404 if server timeout expires (1003ms)
  ✓ responds with 404 if client timeout expires (1002ms)

Existing index files
  ✓ responds immediately for index existing-index.html

Non-existing index files
  ✓ responds immediately with 404 without header 
  ✓ responds with 404 if timeout expires (4006ms)
  ✓ responds with 200 if file is created before timeout expires (2007ms)

Prefer Header Parsing
  ✓ handles no Prefer header 
  ✓ handles non-matching preference with no value 
  ✓ handles non-matching preference with value 
  ✓ handles matching preference with no value 
  ✓ handles matching preference with value 
  ✓ handles matching preference with value and other preferences 
  ✓ handles duplicate preference with one value 
  ✓ handles duplicate preference with multiple values


20 passing (16s)

The "wait" preference is in seconds, which makes the tests much slower. But, it's a small price to pay to use pre-existing functionality (since the whole point of this proposal is to avoid reinventing wheels).

My testing kick also extended to the MPEG-TS media segment DASH conformance tests, and I'll post about that sometime soon.