summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2019-04-19 10:10:54 +0000
committerVincent Schippefilt <vsc@odoo.com>2019-05-20 08:52:18 +0000
commit8a28cc22fd242f5fb59f23d1443ed8ed438249d7 (patch)
tree85b2df5a1f58f84ee5ef931aaa31d175e5646f0c /addons/web/static/src/js/services
parentd9b0b09bd2a9a359ff04d28fd1a6f5c06f89f378 (diff)
[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 <jum@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/services')
-rw-r--r--addons/web/static/src/js/services/data_manager.js4
1 files changed, 3 insertions, 1 deletions
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];