emikulic / darkhttpd

When you need a web server in a hurry.
https://unix4lyfe.org/darkhttpd/
ISC License
1.03k stars 83 forks source link

Is the date header necessary? #43

Closed hhartzer closed 6 months ago

hhartzer commented 7 months ago

In the spirit of slim code, I wonder if the HTTP Date header is necessary. I can think of few cases where it might be pertinent.

Here's a discussion on the topic: https://stackoverflow.com/questions/1610254/whats-the-rationale-behind-the-http-date-header

RFC: https://www.rfc-editor.org/rfc/rfc7231#section-7.1.1.2

If someone does benefit from the date header I am genuinely curious as its use has always eluded me.

If the conclusion is that it is indeed unnecessary, I would be happy to provide a pull request to help offset some of the lines I'd added.

emikulic commented 6 months ago

I don't know the answer to this. I'm happy to just leave it in though.

Chrome code seems to use the Date header for something caching related: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/media/cache_util.cc;l=45;drc=aba625cb0ffe11a87d54b6120fed500a7dee3262

hhartzer commented 6 months ago

Interesting! I hadn't seen that.

Leaving it in may be the best way to go. If I understand correctly (both in general and with that code), however, I don't think the caching logic works without etag/cache-control/last modified headers. In some very edge cases the date header can be a privacy concern, but certainly not a significant one.

The RFC does say that the client should insert its own date if the server does not offer one.

I'm happy to close this out if you like.

emikulic commented 6 months ago

In my experience, caching is a bit fiddly. Let's go ahead and close this out.