From 2b79294500cfef2a57d8fa4201e7a891406b7f9b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 20:27:23 +0200 Subject: [PATCH] [ADD] cache bzr revid: fme@openerp.com-20140410182723-x1aoo2o0zhgkvwsf --- addons/web/controllers/main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6ef14d56f27..d8e4dd9d972 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -595,8 +595,15 @@ class Home(http.Controller): bundle.last_modified if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) + headers = [('Content-Type', 'application/javascript')] + + if True: + # WIP: decide best cache settings + headers.append(('Cache-Control', 'max-age=%s' % (60*5))) + return request.make_response(bundle.js(), headers) + return make_conditional( - request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]), + request.make_response(bundle.js(), headers), bundle.last_modified, bundle.checksum) @http.route('/web/css/', type='http', auth='none') @@ -606,8 +613,15 @@ class Home(http.Controller): bundle = AssetsBundle(xmlid, assets_html) if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) + headers = [('Content-Type', 'text/css')] + + if True: + # WIP: decide best cache settings + headers.append(('Cache-Control', 'max-age=%s' % (60*5))) + return request.make_response(bundle.css(), headers) + return make_conditional( - request.make_response(bundle.css(), [('Content-Type', 'text/css')]), + request.make_response(bundle.css(), headers), bundle.last_modified, bundle.checksum) class WebClient(http.Controller):