Add Expires header to favicon controller responses
parent
dd05d95dba
commit
5529b66a57
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue