Commit a42e0c8
committed
fix(http): Last-Modified is the file's mtime, not now()
Every static file was served with Last-Modified = SystemTime::now(), so the
header advanced by a second between two requests for a file that had not
changed. A client doing If-Modified-Since revalidation could never get a
meaningful answer and no cache could key on it.
FileSystem::modified_at reads the real mtime with the same local-then-database
fallback read_file uses, so the timestamp describes the file actually served.
DbFsQueries gains a prepared statement for the last_modified column, mirroring
the existing was_modified/read_file/exists trio.
The header is OMITTED when no mtime is available rather than filled with a
guess: a header that says "now" is worse than an absent one, because a client
believes it.
Both filesystems now compare with `>`. They disagreed - local `>`, DB `>=` - so
the same request answered differently depending only on where the file was
stored. `>` is the correct half rather than merely the chosen one:
If-Modified-Since: T asks whether the file changed AFTER T, so an mtime of
exactly T is not a change and must answer 304. I had this as `>=` first and
driving the repro caught it - every revalidation re-sent the whole body, which
defeats the header this change exists to fix.
Verified against the issue's reproduction: mtime reported correctly, stable
across requests, and 304/200/304 for If-Modified-Since equal to / older than /
newer than the mtime.
Fixes #13231 parent 109b20d commit a42e0c8
2 files changed
Lines changed: 116 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
101 | 145 | | |
102 | 146 | | |
103 | 147 | | |
| |||
271 | 315 | | |
272 | 316 | | |
273 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
274 | 329 | | |
275 | 330 | | |
276 | 331 | | |
277 | 332 | | |
278 | 333 | | |
| 334 | + | |
279 | 335 | | |
280 | 336 | | |
281 | 337 | | |
| |||
304 | 360 | | |
305 | 361 | | |
306 | 362 | | |
| 363 | + | |
307 | 364 | | |
308 | 365 | | |
309 | 366 | | |
| |||
320 | 377 | | |
321 | 378 | | |
322 | 379 | | |
323 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
324 | 385 | | |
325 | 386 | | |
326 | 387 | | |
| |||
332 | 393 | | |
333 | 394 | | |
334 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
335 | 406 | | |
336 | 407 | | |
337 | 408 | | |
| |||
351 | 422 | | |
352 | 423 | | |
353 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
354 | 451 | | |
355 | 452 | | |
356 | 453 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
458 | 466 | | |
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | 470 | | |
463 | 471 | | |
464 | 472 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
473 | 483 | | |
474 | 484 | | |
475 | 485 | | |
| |||
0 commit comments