[pmg-devel] [PATCH pmg-api 1/1] pmgproxy: implement cache workaround

Dominik Csapak d.csapak at proxmox.com
Thu Nov 28 11:22:43 CET 2019


we include the version of the packages in the temlate, so that
we  can tell the browser that the file has changed and thus preventing
to load an old gui js file
the index template has to add the version to the get parameter

this is the same logic we use as in PVEs pveproxy

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PMG/Service/pmgproxy.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/PMG/Service/pmgproxy.pm b/src/PMG/Service/pmgproxy.pm
index 6249c55..e88d757 100755
--- a/src/PMG/Service/pmgproxy.pm
+++ b/src/PMG/Service/pmgproxy.pm
@@ -215,6 +215,19 @@ sub get_index {
 	$langfile = 1;
     }
 
+    my $wtversionraw = PVE::Tools::file_read_firstline("$widgettoolkit_dir/proxmoxlib.js");
+    my $wtversion = '';
+    if ($wtversionraw =~ m|^// (.*)$|) {
+	$wtversion = $1;
+    };
+
+    my $versionraw = PVE::Tools::file_read_firstline("$gui_base_dir/js/pmgmanagerlib.js");
+    my $version = '';
+    if ($versionraw =~ m|^// (.*)$|) {
+	$version = $1;
+    };
+
+
     $username = '' if !$username;
 
     my $page = '';
@@ -227,6 +240,8 @@ sub get_index {
 	console => $args->{console},
 	nodename => $nodename,
 	debug => $args->{debug} || $server->{debug},
+	version => $version,
+	wtversion => $wtversion,
     };
 
     my $template_name;
-- 
2.20.1




More information about the pmg-devel mailing list