Commit 91667964 authored by Roque's avatar Roque

erp5_web_renderjs_ui: return modification date in precache json dict script response

parent 4cb13be9
No related merge requests found
web_section = context web_section = context
if REQUEST is not None:
modification_date_string = web_section.getModificationDate().rfc822()
weak_etag_header = 'W/"%s"' % modification_date_string
REQUEST.RESPONSE.setHeader('ETag', weak_etag_header)
if_none_match = REQUEST.getHeader('If-None-Match', '')
#using 'in' instead of '==' because the header value may contain a suffix
#for the server HTTP compression. e.g. "-gzip" suffix for DeflateAlterETag on apache
if weak_etag_header[:-1] in if_none_match:
REQUEST.RESPONSE.setStatus(304)
return ""
# Add all ERP5JS gadget # Add all ERP5JS gadget
url_list = [ url_list = [
'favicon.ico', 'favicon.ico',
...@@ -197,7 +186,11 @@ for precache_manifest_script_id in precache_manifest_url_list: ...@@ -197,7 +186,11 @@ for precache_manifest_script_id in precache_manifest_url_list:
if REQUEST is not None: if REQUEST is not None:
import json import json
manifest_dict = {
'url_dict': dict.fromkeys(url_list),
'modification_date': context.getModificationDate().rfc822()
}
REQUEST.RESPONSE.setHeader('Content-Type', 'application/json') REQUEST.RESPONSE.setHeader('Content-Type', 'application/json')
return json.dumps(dict.fromkeys(url_list), indent=2) return json.dumps(manifest_dict, indent=2)
return list(set(url_list)) return list(set(url_list))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment