From 875032f0dcb04879daea3911be629741a85c3b11 Mon Sep 17 00:00:00 2001 From: Sam Eaton Date: Tue, 11 Oct 2016 15:51:37 -0600 Subject: [PATCH] removes Content-Type response header if the file is cached The content-type currently defaults to text/html, which is inaccurate because no content is being returned. Google, and many popular CDNs omit the Content-Type header for 304 response. --- src/kemal/static_file_handler.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kemal/static_file_handler.cr b/src/kemal/static_file_handler.cr index f3b4d67..4e26d51 100644 --- a/src/kemal/static_file_handler.cr +++ b/src/kemal/static_file_handler.cr @@ -80,6 +80,7 @@ module Kemal etag = %{W/"#{File.lstat(file_path).mtime.epoch.to_s}"} context.response.headers["ETag"] = etag return false if !context.request.headers["If-None-Match"]? || context.request.headers["If-None-Match"] != etag + context.response.headers.delete "Content-Type" context.response.content_length = 0 context.response.status_code = 304 # not modified return true