[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
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user