From 1b8a1f77501acbb7634206812717ac9fedf8320d Mon Sep 17 00:00:00 2001 From: IntelliDust Date: Thu, 3 Dec 2015 12:48:27 +0100 Subject: [PATCH 1/2] Added handling of watchdog for serving bigger files --- httpserver-static.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/httpserver-static.lua b/httpserver-static.lua index d7cb86f..df65c26 100644 --- a/httpserver-static.lua +++ b/httpserver-static.lua @@ -23,6 +23,7 @@ return function (connection, req, args) connection:send(chunk) bytesSent = bytesSent + #chunk chunk = nil + tmr.wdclr() -- loop can take a while for long files. tmr.wdclr() prevent watchdog to restart module --print("Sent" .. args.file, bytesSent) end end From 1f43c9f5e592139aece16c7c08ab00960a68dd97 Mon Sep 17 00:00:00 2001 From: IntelliDust Date: Thu, 3 Dec 2015 12:51:42 +0100 Subject: [PATCH 2/2] Added Cache-Control header for gzipped content. This will prevent for getting css.gz js.gz and so by browser from server. --- httpserver-header.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/httpserver-header.lua b/httpserver-header.lua index 4284dcf..62f9fe2 100644 --- a/httpserver-header.lua +++ b/httpserver-header.lua @@ -23,6 +23,7 @@ return function (connection, code, extension, gzip) connection:send("HTTP/1.0 " .. code .. " " .. getHTTPStatusString(code) .. "\r\nServer: nodemcu-httpserver\r\nContent-Type: " .. mimeType["contentType"] .. "\r\n") if gzip then + connection:send("Cache-Control: max-age=2592000\r\n") connection:send("Content-Encoding: gzip\r\n") end connection:send("Connection: close\r\n\r\n")