diff options
| author | Jeremy Kersten <jke@odoo.com> | 2020-03-13 15:16:35 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2020-03-19 15:37:47 +0000 |
| commit | c2142a34f73cb8329e8d214596484bd9a581b3e6 (patch) | |
| tree | 0da4bf1ac11a71c285a94ac3b20028ad380e6482 /addons/web/models | |
| parent | e27eb978a6e4283510e4704fe574585e4ee27d64 (diff) | |
[FIX] website: perf - cache the compute hash for translation
Before this commit, we compute the hash on each request, to know if we need to
download the file from the frontend or if we can use cache.
Now we store the hash computed in cache. The cache will be invalidated when we
touch one of these translations (openerp-web in the comments) or when you
install a new lang (already the case).
+ avoid to use read on a record, since it will not use the cache from record.
Related to #47257
task-2211013
X-original-commit: d5aaecbc51de19ef1d8d9988b691177fc73a4b86
Diffstat (limited to 'addons/web/models')
| -rw-r--r-- | addons/web/models/ir_http.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/addons/web/models/ir_http.py b/addons/web/models/ir_http.py index fd4e3bc923e..3c5839aa042 100644 --- a/addons/web/models/ir_http.py +++ b/addons/web/models/ir_http.py @@ -50,19 +50,12 @@ class Http(models.AbstractModel): mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum(addons=mods, debug=request.session.debug) lang = user_context.get("lang") - translations_per_module, lang_params = request.env['ir.translation'].get_translations_for_webclient(mods, lang) - translation_cache = { - 'lang': lang, - 'lang_parameters': lang_params, - 'modules': translations_per_module, - 'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1, - } + translation_hash = request.env['ir.translation'].get_web_translations_hash(mods, lang) menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus(request.session.debug), default=ustr, sort_keys=True).encode() - translations_json_utf8 = json.dumps(translation_cache, sort_keys=True).encode() cache_hashes = { "load_menus": hashlib.sha512(menu_json_utf8).hexdigest()[:64], # sha512/256 "qweb": qweb_checksum, - "translations": hashlib.sha512(translations_json_utf8).hexdigest()[:64], # sha512/256 + "translations": translation_hash, } session_info.update({ # current_company should be default_company |
