From f6f82b52eb72726abc7732d21e54aa43dd8b5058 Mon Sep 17 00:00:00 2001 From: Oleg S Date: Mon, 14 Apr 2025 16:08:45 +0300 Subject: [PATCH] luci-base: package update based cache-busting string Problem: After updating the JS-part of any package, the user is forced to clear the browser cache. Fix: Each time a package is removed or installed, the contents of the "/lib/apk/db/installed" file are changed. This fix add the modification time of the "/lib/apk/db/installed" file to the version of the main LuCI package (for each js-file). Signed-off-by: Oleg S --- modules/luci-base/ucode/runtime.uc | 3 ++- modules/luci-base/ucode/template/header.ut | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/luci-base/ucode/runtime.uc b/modules/luci-base/ucode/runtime.uc index f14bf74480..e5f11690df 100644 --- a/modules/luci-base/ucode/runtime.uc +++ b/modules/luci-base/ucode/runtime.uc @@ -1,7 +1,7 @@ // Copyright 2022 Jo-Philipp Wich // Licensed to the public under the Apache License 2.0. -import { access, basename } from 'fs'; +import { access, basename, stat } from 'fs'; import { cursor } from 'uci'; const template_directory = '/usr/share/ucode/luci/template'; @@ -179,6 +179,7 @@ export default function(env) { self.env.media = media; self.env.theme = basename(media); self.env.resource = uci.get('luci', 'main', 'resourcebase'); + self.env.pkgs_update_time = stat('/lib/apk/db/installed')?.mtime ?? stat('/usr/lib/opkg/status')?.mtime ?? 0; self.env.include = (...args) => self.render_any(...args); return self; diff --git a/modules/luci-base/ucode/template/header.ut b/modules/luci-base/ucode/template/header.ut index 7a8462d61d..f23e5e45c8 100644 --- a/modules/luci-base/ucode/template/header.ut +++ b/modules/luci-base/ucode/template/header.ut @@ -7,7 +7,7 @@ include(`themes/${theme}/header`); -%} - +