From 43ee6b9f5bfaaaff18c08ad6e084108997e22eb5 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 21 Feb 2024 18:44:56 +0000 Subject: [PATCH] stop cloudflare from jumbling up png/svg icons; chrome crashes if there's more than 2000 unique SVGs on one page, so there was serverside useragent-sniffing to determine if the icon should be an svg or a raster however since the useragent is not in our vary, cloudflare wouldn't see the difference and cache everything equally, meaning most folders would display a random mix of png and svg thumbnails move browser detection to the clientside to ensure unique URLs --- copyparty/httpcli.py | 5 +++-- copyparty/web/browser.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 12a92e91..643c7cf5 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -3142,8 +3142,9 @@ class HttpCli(object): ext = "~" + ext[-9:] # chrome cannot handle more than ~2000 unique SVGs - chrome = " rv:" not in self.ua - mime, ico = self.ico.get(ext, not exact, chrome) + # so url-param "raster" returns a png/webp instead + # (useragent-sniffing kinshi due to caching proxies) + mime, ico = self.ico.get(ext, not exact, "raster" in self.uparam) lm = formatdate(self.E.t0, usegmt=True) self.reply(ico, mime=mime, headers={"Last-Modified": lm}) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 6102a866..03fb2339 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -4847,6 +4847,8 @@ var thegrid = (function () { ihref = SR + '/.cpr/ico/' + ext; } ihref += (ihref.indexOf('?') > 0 ? '&' : '?') + 'cache=i&_=' + ACB; + if (CHROME) + ihref += "&raster"; html.push('