couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject chttpd commit: updated refs/heads/master to 599b095
Date Mon, 14 Mar 2016 04:25:50 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master bdcaad96c -> 599b0953c


Cache favicon for one year


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/599b0953
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/599b0953
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/599b0953

Branch: refs/heads/master
Commit: 599b0953c26da40850e43e9ca125940eff8a12e7
Parents: bdcaad9
Author: Alexander Shorin <kxepal@apache.org>
Authored: Sun Mar 6 17:15:15 2016 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Mon Mar 14 07:24:57 2016 +0300

----------------------------------------------------------------------
 src/chttpd_misc.erl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/599b0953/src/chttpd_misc.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_misc.erl b/src/chttpd_misc.erl
index a9c7051..0f573cb 100644
--- a/src/chttpd_misc.erl
+++ b/src/chttpd_misc.erl
@@ -59,7 +59,16 @@ handle_favicon_req(Req) ->
     handle_favicon_req(Req, config:get("chttpd", "docroot")).
 
 handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) ->
-    chttpd:serve_file(Req, "favicon.ico", DocumentRoot);
+    {DateNow, TimeNow} = calendar:universal_time(),
+    DaysNow = calendar:date_to_gregorian_days(DateNow),
+    DaysWhenExpires = DaysNow + 365,
+    DateWhenExpires = calendar:gregorian_days_to_date(DaysWhenExpires),
+    CachingHeaders = [
+        %favicon should expire a year from now
+        {"Cache-Control", "public, max-age=31536000"},
+        {"Expires", couch_util:rfc1123_date({DateWhenExpires, TimeNow})}
+    ],
+    chttpd:serve_file(Req, "favicon.ico", DocumentRoot, CachingHeaders);
 handle_favicon_req(Req, _) ->
     send_method_not_allowed(Req, "GET,HEAD").
 


Mime
View raw message