[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user