From 5529b66a57adb18b43f12fa08e3a75e697e6c64a Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 19 Nov 2012 17:30:13 -0600 Subject: [PATCH] Add Expires header to favicon controller responses --- src/milla/controllers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/milla/controllers.py b/src/milla/controllers.py index 576adc4..7e59fa0 100644 --- a/src/milla/controllers.py +++ b/src/milla/controllers.py @@ -23,7 +23,8 @@ from one or more of these classes can make things significantly easier. :Updater: $Author$ ''' -import milla +import datetime +import milla.util import pkg_resources @@ -53,6 +54,9 @@ class FaviconController(Controller): used as the favicon, defaults to 'image/x-icon' (Windows ICO format) ''' + #: Number of days in the future to set the cache expiration for the icon + EXPIRY_DAYS = 365 + def __init__(self, icon=None, content_type='image/x-icon'): if icon: try: @@ -72,4 +76,7 @@ class FaviconController(Controller): response = milla.Response() response.app_iter = self.icon response.headers['Content-Type'] = self.content_type + expires = (datetime.datetime.utcnow() + + datetime.timedelta(days=self.EXPIRY_DAYS)) + response.headers['Expires'] = milla.util.http_date(expires) return response