[IMP] base: server_attachment add max-age when unique is provided

Similarly to method _binary_set_headers, when we serve an attachment
(e.g. image) where an unique is present in URL we add a long time of cache.

We considere that the hash will be changed if attachment is updated, so
while we ask for same checksum, lets the browser return the cached response.

closes odoo/odoo#48653

Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Jeremy Kersten
2020-03-31 08:54:52 +00:00
parent 66409d470e
commit f7d7c53cd5
+4 -1
View File
@@ -162,7 +162,10 @@ class IrHttp(models.AbstractModel):
response.last_modified = wdate
response.set_etag(checksum)
response.make_conditional(request.httprequest)
response.make_conditional(
request.httprequest,
max_age=http.STATIC_CACHE_LONG if request.params.get('unique') else 0
)
if response.status_code == 304:
return response