diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index bd9bb6c6..3390907d 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -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 diff --git a/copyparty/web/md2.js b/copyparty/web/md2.js index c33b506c..77fbc300 100644 --- a/copyparty/web/md2.js +++ b/copyparty/web/md2.js @@ -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);