Добавление кэширования
authorlapayx <lapayx@mail.ru>
Sun, 18 Oct 2015 18:56:52 +0000 (21:56 +0300)
committerlapayx <lapayx@mail.ru>
Sun, 18 Oct 2015 18:56:52 +0000 (21:56 +0300)
src/xupnpd_http.lua

index 7a12a61..919ed60 100644 (file)
@@ -97,11 +97,28 @@ function compile_templates()
 end
 
 function http_send_headers(err,ext,len)
+
+http_cahce= {}
+http_cahce['html']='max-age=3600'
+http_cahce['jpg']='max-age=3600'
+http_cahce['png']='max-age=3600'
+http_cahce['ico']='max-age=3600'
+http_cahce['css']='max-age=3600'
+http_cahce['js']='max-age=3600'
+
     http.send(
         string.format(
-            'HTTP/1.1 %i %s\r\nPragma: no-cache\r\nCache-control: no-cache\r\nDate: %s\r\nServer: %s\r\nAccept-Ranges: none\r\n'..
-            'Connection: close\r\nContent-Type: %s\r\nEXT:\r\n',
-            err,http_err[err] or 'Unknown',os.date('!%a, %d %b %Y %H:%M:%S GMT'),ssdp_server,http_mime[ext] or 'application/x-octet-stream')
+            'HTTP/1.1 %i %s\r\n'..
+            'Pragma: no-cache\r\n'..
+            'Cache-control: %s\r\n'..
+            'Date: %s\r\n'..
+            'Server: %s\r\n'..
+            'Accept-Ranges: none\r\n'..
+            'Connection: close\r\n'..
+            'Content-Type: %s\r\nEXT:\r\n',
+             err,http_err[err] or 'Unknown',
+             http_cahce[ext] or 'no-cache',
+             os.date('!%a, %d %b %Y %H:%M:%S GMT'),ssdp_server,http_mime[ext] or 'application/x-octet-stream')
     )
     if len then http.send(string.format("Content-Length: %s\r\n",len)) end
     http.send("\r\n")