Commit 97891b1a authored by Roque's avatar Roque

Erp5 officejs fix cache

See merge request nexedi/erp5!1227
parents 410744dc 2e547774
Pipeline #10901 failed with stage
in 0 seconds
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
}) })
.push(function (evt) { .push(function (evt) {
var key, var key,
precache_dict = evt.target.response, precache_dict = evt.target.response.url_dict,
result_list = [], result_list = [],
precache_absolute_url = (new URL(precache_url, window.location)).href; precache_absolute_url = (new URL(precache_url, window.location)).href;
for (key in precache_dict) { for (key in precache_dict) {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.51931.38103.24746</string> </value> <value> <string>985.49101.35647.15445</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1581590120.37</float> <float>1596722312.92</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -22,7 +22,11 @@ url_list = [ ...@@ -22,7 +22,11 @@ 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 url_list return url_list
...@@ -101,10 +101,8 @@ ...@@ -101,10 +101,8 @@
var base_manifest_text = response.target.responseText, var base_manifest_text = response.target.responseText,
relative_url_list, relative_url_list,
i, i,
hash = rusha.digestFromString(base_manifest_text + hash = rusha.digestFromString(base_manifest_text);
response.target relative_url_list = Object.keys(JSON.parse(base_manifest_text).url_dict);
.getResponseHeader("ETag"));
relative_url_list = Object.keys(JSON.parse(base_manifest_text));
storage._relative_url_list.push(storage._version); storage._relative_url_list.push(storage._version);
storage._relative_url_list.push(storage._version + storage._relative_url_list.push(storage._version +
storage._precache_manifest_script); storage._precache_manifest_script);
......
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