luci-base: package update based cache-busting string#7725
Conversation
|
Please try this approach instead: diff --git a/modules/luci-base/ucode/runtime.uc b/modules/luci-base/ucode/runtime.uc
index f14bf74480..81afac9f60 100644
--- a/modules/luci-base/ucode/runtime.uc
+++ b/modules/luci-base/ucode/runtime.uc
@@ -1,7 +1,7 @@
// Copyright 2022 Jo-Philipp Wich <jo@mein.io>
// 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.resource_version = stat('/usr/lib/opkg/status')?.mtime ?? stat('/lib/apk/db/installed')?.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..e15069333d 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`);
-%}
-<script src="{{ resource }}/luci.js"></script>
+<script src="{{ resource }}/luci.js?v={# PKG_VERSION #}-{{ resource_version }}"></script>
<script>
L = new LuCI({{ replace(`${ {
media : media,
|
|
The |
I like this (@jow-'s) approach - this was abstractly what I had in mind when I commented in the forums. |
|
I would swap the two paths around since SNAPSHOT is all apk from here on in: + self.env.resource_version = stat('/lib/apk/db/installed')?.mtime ?? stat('/usr/lib/opkg/status')?.mtime ?? 0; |
|
Perhaps name |
let @jow- make a new commit. So that everything is perfect. |
|
You're already here doing it @remittor - just update your commits :) |
|
You weren't asked to. |
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 <remittor@gmail.com>
|
Merged. Thanks @remittor |
|
The cause has been identified: this is a custom Argon theme ;-) Same problem: |






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/installedfile are changed.This fix add the modification time of the
/lib/apk/db/installedfile to the version of the main LuCI package (for eachjs-file).Additional info and screenshots: https://forum.openwrt.org/t/214025/3
Signed-off-by: <my@email.address>row (viagit commit --signoff)<package name>: luci-basefirst line subject for packagesPKG_VERSIONin the Makefile