From 75a7ed132aa2b9afdeae45065ca607bf1cc89c19 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 28 Nov 2025 08:08:43 -0500 Subject: [PATCH] Fix stale UI after firmware updates (#5120) Add WEB_BUILD_TIME to html_ui.h and use it for ETag generation Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com> Co-authored-by: Aircoookie <21045690+Aircoookie@users.noreply.github.com> --- tools/cdata.js | 8 ++++++++ wled00/wled_server.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/cdata.js b/tools/cdata.js index c569a6f2..759d24c2 100644 --- a/tools/cdata.js +++ b/tools/cdata.js @@ -38,6 +38,11 @@ const wledBanner = ` \t\t\x1b[36m build script for web UI \x1b[0m`; +// Generate build timestamp as UNIX timestamp (seconds since epoch) +function generateBuildTime() { + return Math.floor(Date.now() / 1000); +} + const singleHeader = `/* * Binary array for the Web UI. * gzip is used for smaller size and improved speeds. @@ -45,6 +50,9 @@ const singleHeader = `/* * Please see https://kno.wled.ge/advanced/custom-features/#changing-web-ui * to find out how to easily modify the web UI source! */ + +// Automatically generated build time for cache busting (UNIX timestamp) +#define WEB_BUILD_TIME ${generateBuildTime()} `; diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index d899d311..09aeaccf 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -67,7 +67,7 @@ static bool inLocalSubnet(const IPAddress &client) { */ static void generateEtag(char *etag, uint16_t eTagSuffix) { - sprintf_P(etag, PSTR("%7d-%02x-%04x"), VERSION, cacheInvalidate, eTagSuffix); + sprintf_P(etag, PSTR("%u-%02x-%04x"), WEB_BUILD_TIME, cacheInvalidate, eTagSuffix); } static void setStaticContentCacheHeaders(AsyncWebServerResponse *response, int code, uint16_t eTagSuffix = 0) {