thumbnail caching

This commit is contained in:
ed 2021-10-24 00:29:04 +02:00
parent f7a4ea5793
commit 060dc54832
2 changed files with 19 additions and 4 deletions

View file

@ -274,6 +274,15 @@ class HttpCli(object):
except Pebkac:
return False
def permit_caching(self):
cache = self.uparam.get("cache")
if cache is None:
self.out_headers.update(NO_CACHE)
return
n = "604800" if cache == "i" else cache or "69"
self.out_headers["Cache-Control"] = "max-age=" + n
def send_headers(self, length, status=200, mime=None, headers=None):
response = ["{} {} {}".format(self.http_ver, status, HTTPCODE[status])]
@ -1449,10 +1458,8 @@ class HttpCli(object):
if is_compressed:
self.out_headers["Cache-Control"] = "max-age=573"
elif "cache" in self.uparam:
self.out_headers["Cache-Control"] = "max-age=69"
else:
self.out_headers.update(NO_CACHE)
self.permit_caching()
self.out_headers["Accept-Ranges"] = "bytes"
self.send_headers(
@ -1548,6 +1555,7 @@ class HttpCli(object):
return True
def tx_ico(self, ext, exact=False):
self.permit_caching()
if ext.endswith("/"):
ext = "folder"
exact = True

View file

@ -2488,9 +2488,11 @@ var thegrid = (function () {
}
ihref = '/.cpr/ico/' + ihref.slice(0, -1);
}
ihref += (ihref.indexOf('?') > 0 ? '&' : '?') + 'cache=i';
html.push('<a href="' + ohref + '" ref="' + ref +
'"' + ac + ' ttt="' + esc(name) + '"><img src="' +
'"' + ac + ' ttt="' + esc(name) + '"><img style="height:' +
(r.sz / 1.25) + 'em" onload="th_onload(this)" src="' +
ihref + '" /><span' + ac + '>' + ao.innerHTML + '</span></a>');
}
ebi('ggrid').innerHTML = html.join('\n');
@ -2549,6 +2551,11 @@ var thegrid = (function () {
})();
function th_onload(el) {
el.style.height = '';
}
function tree_scrollto(e) {
ev(e);
var act = QS('#treeul a.hl'),