[PATCH 0/4] HTTPD: Add caching

2020-08-08 Thread Sergey Ponomarev
Date and Last-Modified headers now can be disabled while there still enabled by default. I hope in future versions they become disabled by default and later removed at all. I checked and Cache-Control works fine in Chrome and Firefox even if Date is not present. Last-Modified can be replaced

[PATCH 1/4] httpd: Update to HTTP/1.1

2020-08-08 Thread Sergey Ponomarev
HTTP v1.1 was released in 1999 year and it's time to update BB HTTPD. Browsers may behave badly with HTTP/1.0 E.g. Chrome not sends the If-None-Match header with ETag. Signed-off-by: Sergey Ponomarev --- networking/httpd.c | 16 1 file changed, 8 insertions(+), 8 deletions(-)

[PATCH 2/4] httpd: Don't add Date header to response

2020-08-08 Thread Sergey Ponomarev
In RFC 2616 sec. 14.18 said that sever MUST send Date header. But in fact the header have sense only for Cache-Control and can be omitted. In the same time the Date eats power, CPU and network resources which are critical for embedded systems. Signed-off-by: Sergey Ponomarev ---

[PATCH 4/4] httpd: Support caching via ETag header

2020-08-08 Thread Sergey Ponomarev
If server respond with ETag then next time client (browser) resend it via If-None-Match header. Then httpd will check if file wasn't modified and if not return 304 Not Modified status code. The ETag value is constructed from file's last modification date in unix epoch and it's size:

[PATCH 3/4] httpd: Don't add Last-Modified header to response

2020-08-08 Thread Sergey Ponomarev
The Last-Modified header is used for caching. The client (browser) will send back the received date to server via If-Modified-Since request header. But both headers MUST be an RFC 1123 formatted string. And the formatting consumes resources on request parsing and response generation. Instead we