couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r889402 - in /couchdb/trunk: THANKS src/couchdb/couch_httpd.erl src/couchdb/couch_httpd_misc_handlers.erl
Date Thu, 10 Dec 2009 20:10:30 GMT
Author: jchris
Date: Thu Dec 10 20:10:29 2009
New Revision: 889402

URL: http://svn.apache.org/viewvc?rev=889402&view=rev
Log:
cache headers for favicon.ico - thanks Matthew Hooker

Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=889402&r1=889401&r2=889402&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Thu Dec 10 20:10:29 2009
@@ -39,5 +39,6 @@
  * Gustavo Niemeyer
  * Joshua Bronson <jabronson@gmail.com>
  * Kostis Sagonas <kostis@cs.ntua.gr>
+ * Matthew Hooker <mwhooker@gmail.com>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=889402&r1=889401&r2=889402&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Thu Dec 10 20:10:29 2009
@@ -18,7 +18,7 @@
 -export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]).
 -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
 -export([parse_form/1,json_body/1,json_body_obj/1,body/1,doc_etag/1, make_etag/1, etag_respond/3]).
--export([primary_header_value/2,partition/1,serve_file/3, server_header/0]).
+-export([primary_header_value/2,partition/1,serve_file/3,serve_file/4, server_header/0]).
 -export([start_chunked_response/3,send_chunk/2,log_request/2]).
 -export([start_response_length/4, send/2]).
 -export([start_json_response/2, start_json_response/3, end_json_response/1]).
@@ -245,8 +245,11 @@
     MochiReq:get_primary_header_value(Key).
 
 serve_file(#httpd{mochi_req=MochiReq}=Req, RelativePath, DocumentRoot) ->
+    serve_file(Req, RelativePath, DocumentRoot, []).
+
+serve_file(#httpd{mochi_req=MochiReq}=Req, RelativePath, DocumentRoot, ExtraHeaders) ->
     {ok, MochiReq:serve_file(RelativePath, DocumentRoot,
-        server_header() ++ couch_httpd_auth:cookie_auth_header(Req, []))}.
+        server_header() ++ couch_httpd_auth:cookie_auth_header(Req, []) ++ ExtraHeaders)}.
 
 qs_value(Req, Key) ->
     qs_value(Req, Key, undefined).

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=889402&r1=889401&r2=889402&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Thu Dec 10 20:10:29 2009
@@ -38,7 +38,14 @@
     send_method_not_allowed(Req, "GET,HEAD").
 
 handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) ->
-    couch_httpd:serve_file(Req, "favicon.ico", DocumentRoot);
+    {{Year,Month,Day},Time} = erlang:localtime(),
+    OneYearFromNow = {{Year+1,Month,Day},Time},
+    CachingHeaders = [
+        %favicon should expire a year from now
+        {"Cache-Control", "public, max-age=31536000"},
+        {"Expires", httpd_util:rfc1123_date(OneYearFromNow)}
+    ],
+    couch_httpd:serve_file(Req, "favicon.ico", DocumentRoot, CachingHeaders);
 handle_favicon_req(Req, _) ->
     send_method_not_allowed(Req, "GET,HEAD").
 



Mime
View raw message