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
This commit is contained in:
ed 2024-02-21 18:44:56 +00:00
parent 8a38101e48
commit 43ee6b9f5b
2 changed files with 5 additions and 2 deletions

View file

@ -3142,8 +3142,9 @@ class HttpCli(object):
ext = "~" + ext[-9:] ext = "~" + ext[-9:]
# chrome cannot handle more than ~2000 unique SVGs # chrome cannot handle more than ~2000 unique SVGs
chrome = " rv:" not in self.ua # so url-param "raster" returns a png/webp instead
mime, ico = self.ico.get(ext, not exact, chrome) # (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) lm = formatdate(self.E.t0, usegmt=True)
self.reply(ico, mime=mime, headers={"Last-Modified": lm}) self.reply(ico, mime=mime, headers={"Last-Modified": lm})

View file

@ -4847,6 +4847,8 @@ var thegrid = (function () {
ihref = SR + '/.cpr/ico/' + ext; ihref = SR + '/.cpr/ico/' + ext;
} }
ihref += (ihref.indexOf('?') > 0 ? '&' : '?') + 'cache=i&_=' + ACB; ihref += (ihref.indexOf('?') > 0 ? '&' : '?') + 'cache=i&_=' + ACB;
if (CHROME)
ihref += "&raster";
html.push('<a href="' + ohref + '" ref="' + ref + html.push('<a href="' + ohref + '" ref="' + ref +
'"' + ac + ' ttt="' + esc(name) + '"><img style="height:' + '"' + ac + ' ttt="' + esc(name) + '"><img style="height:' +