From 2d46dbcbfd122eaf1686623cf8cf319178e31109 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 18 Oct 2017 14:53:10 +0200 Subject: [PATCH] [FIX] ir_http: use meaningful ETag for images (#20283) After setting the image on a product variant, the controller for `/web/image` incorrectly returns the code 304 - Not Modified. This bug occurs because 1. the response ETag is a hash of the **last modified date** of the record; 2. the record is actually **not** updated in that case, because - the image field is a non-stored computed field, and - its inverse method only modifies the variant's template. Fix the issue by making the response ETag a hash of the **content**, which is read by the controller anyway. OPW 769302 --- odoo/addons/base/ir/ir_http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_http.py b/odoo/addons/base/ir/ir_http.py index 1d942e75a86..df15e45df22 100644 --- a/odoo/addons/base/ir/ir_http.py +++ b/odoo/addons/base/ir/ir_http.py @@ -324,7 +324,7 @@ class IrHttp(models.AbstractModel): # cache etag = hasattr(request, 'httprequest') and request.httprequest.headers.get('If-None-Match') - retag = '"%s"' % hashlib.md5(last_update).hexdigest() + retag = '"%s"' % hashlib.md5(content).hexdigest() status = status or (304 if etag == retag else 200) headers.append(('ETag', retag)) headers.append(('Cache-Control', 'max-age=%s' % (STATIC_CACHE if unique else 0)))