fix md-editor lastmod cmp when browsercache is belligerent

This commit is contained in:
ed 2023-07-25 14:06:53 +00:00
parent 0896c5295c
commit 4c843c6df9
2 changed files with 8 additions and 3 deletions

View file

@ -2634,7 +2634,7 @@ class HttpCli(object):
#
# if request is for foo.js, check if we have foo.js.{gz,br}
file_ts = 0
file_ts = 0.0
editions: dict[str, tuple[str, int]] = {}
for ext in ["", ".gz", ".br"]:
try:
@ -2652,7 +2652,7 @@ class HttpCli(object):
else:
sz = st.st_size
file_ts = max(file_ts, int(st.st_mtime))
file_ts = max(file_ts, st.st_mtime)
editions[ext or "plain"] = (fs_path, sz)
except:
pass
@ -2665,11 +2665,14 @@ class HttpCli(object):
#
# if-modified
file_lastmod, do_send = self._chk_lastmod(file_ts)
file_lastmod, do_send = self._chk_lastmod(int(file_ts))
self.out_headers["Last-Modified"] = file_lastmod
if not do_send:
status = 304
if self.can_write:
self.out_headers["X-Lastmod3"] = str(int(file_ts * 1000))
#
# Accept-Encoding and UA decides which edition to send

View file

@ -278,6 +278,7 @@ function Modpoll() {
return;
var new_md = this.responseText,
new_mt = this.getResponseHeader('X-Lastmod3') || r.lastmod,
server_ref = server_md.replace(/\r/g, ''),
server_now = new_md.replace(/\r/g, '');
@ -285,6 +286,7 @@ function Modpoll() {
if (r.initial && server_ref != server_now)
return modal.confirm('Your browser decided to show an outdated copy of the document!\n\nDo you want to load the latest version from the server instead?', function () {
dom_src.value = server_md = new_md;
last_modified = new_mt;
draw_md();
}, null);