From 0f1c403d41f957fc200401affc6e25928a81f09c Mon Sep 17 00:00:00 2001 From: KarnerF Date: Sun, 30 Aug 2026 15:18:17 +0200 Subject: [PATCH] Cache-bust icon img src with timestamp; no-store on 404 to prevent browser caching misses --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index bb426bb..6b2cd32 100644 --- a/main.c +++ b/main.c @@ -1797,10 +1797,10 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { "var ba=img.mounted" "?''" ":'';" - /* /api/icon/{tid} has no query string - safe in img src */ + /* add timestamp to img src to bypass any browser 404 cache */ "var ic=tid" "?'
'" - "+''" + "+''" "+''+tid.substring(0,4)+'
'" ":'
';" "h+='
'+ic;" @@ -2976,11 +2976,11 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { }free(ibuf); }fclose(sf); } - mg_http_reply(c,404,"","");return; + mg_http_reply(c,404,"Cache-Control: no-store\r\n","");return; #undef SMG_IC2 } fseek(fi,0,SEEK_END);long sz2=ftell(fi);fseek(fi,0,SEEK_SET); - if(sz2<=0||sz2>524288){fclose(fi);mg_http_reply(c,404,"","");return;} + if(sz2<=0||sz2>524288){fclose(fi);mg_http_reply(c,404,"Cache-Control: no-store\r\n","");return;} char *buf2=malloc(sz2);if(!buf2){fclose(fi);mg_http_reply(c,500,"","");return;} fread(buf2,1,sz2,fi);fclose(fi); mg_http_reply(c,200,"Content-Type: image/png\r\nCache-Control: max-age=86400\r\n","%.*s",(int)sz2,buf2);