From 8a28cc22fd242f5fb59f23d1443ed8ed438249d7 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Fri, 19 Apr 2019 10:10:54 +0000 Subject: [IMP] base,web: Improve webclient startup Today, some resources that varies very infrequentely are requested on every page load: the menus, the translations and the qweb templates After this commit, there will be 2 improvements that will make the loading of the webclient faster: 1. cache almost static resources forever when loading the /web/ page, the user session will contain the cache key to be used to fetch these resources. As the content of the resource itself it used to compute the hash, the request can be put in cache by the browser forever (for a year). The up side is that in general less requests are needed to load the web client The down side is that the load time and number of queries of /web page has increased to include what is needed to compute the hash of translations, menus and qweb templates 2. trigger the loading of the menus before the download (and startup) of the JS and CSS assets: The menus contains the definition of the action, wich is the first thing needed to load a page in odoo. Starting the loading of the menu much earlier means that when they are not yet in the browser cache (see point 1), the browser does not need to wait for the entire assets to be downloaded and parsed before starting the 'load_menu' request, but instead start it immediately and hold onto a promise to be used instead of the rpc 'load_menu'. Because the request is done before anything else is loaded, including JQuery, it is made in vanilla JS. Co-authored-by: Julien Mougenot --- addons/web/static/src/js/services/data_manager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/services') diff --git a/addons/web/static/src/js/services/data_manager.js b/addons/web/static/src/js/services/data_manager.js index fb9a29a01de..4d66a59eac2 100644 --- a/addons/web/static/src/js/services/data_manager.js +++ b/addons/web/static/src/js/services/data_manager.js @@ -4,6 +4,7 @@ odoo.define('web.DataManager', function (require) { var config = require('web.config'); var core = require('web.core'); var rpc = require('web.rpc'); +var session = require('web.session'); var utils = require('web.utils'); return core.Class.extend({ @@ -26,6 +27,7 @@ return core.Class.extend({ * Suggestion: could be refined to invalidate some part of the cache */ invalidate: function () { + session.invalidateCacheKey('load_menus'); this._init_cache(); }, @@ -45,7 +47,7 @@ return core.Class.extend({ route: "/web/action/load", params: { action_id: action_id, - additional_context : additional_context, + additional_context: additional_context, }, }).then(function (action) { self._cache.actions[key] = action.no_cache ? null : self._cache.actions[key]; -- cgit v1.2.3