[pmg-devel] [PATCH pmg-gui 1/1] add browser cache workaround

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


to prevent indefinite caching of the js files in the browser,
we add the package version to the js files, this will be read
by the pmgproxy and added as template variables

we use those to add the version to the get parameter and
thus tell the browser the file has changed

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Makefile          | 2 ++
 js/Makefile       | 3 ++-
 pmg-index.html.tt | 8 ++++----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 794c7b6..b5ba9d4 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@ IMAGES=				\
 
 CSSFILES = ext6-pmg.css ext6-pmg-mobile.css
 
+export DEB_VERSION_UPSTREAM_REVISION
+
 all:
 
 .PHONY: deb
diff --git a/js/Makefile b/js/Makefile
index e0ac026..353062c 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -106,7 +106,8 @@ lint: ${JSSRC}
 	jslint ${JSSRC} 
 
 pmgmanagerlib.js: OnlineHelpInfo.js ${JSSRC}
-	cat OnlineHelpInfo.js ${JSSRC} >$@.tmp
+	echo "// ${DEB_VERSION_UPSTREAM_REVISION}" > $@.tmp
+	cat OnlineHelpInfo.js ${JSSRC} >> $@.tmp
 	mv $@.tmp $@
 
 pmgmanagerlib-mobile.js: ${MOBILESRC}
diff --git a/pmg-index.html.tt b/pmg-index.html.tt
index 20fa454..4faf0cf 100644
--- a/pmg-index.html.tt
+++ b/pmg-index.html.tt
@@ -11,8 +11,8 @@
     <link rel="stylesheet" type="text/css" href="/pve2/ext6/theme-crisp/resources/theme-crisp-all.css" />
     <link rel="stylesheet" type="text/css" href="/pve2/ext6/crisp/resources/charts-all.css" />
     <link rel="stylesheet" type="text/css" href="/fontawesome/css/font-awesome.css" />
-    <link rel="stylesheet" type="text/css" href="/pve2/css/ext6-pmg.css" />
-    <link rel="stylesheet" type="text/css" href="/pwt/css/ext6-pmx.css" />
+    <link rel="stylesheet" type="text/css" href="/pve2/css/ext6-pmg.css?ver=[% version %]" />
+    <link rel="stylesheet" type="text/css" href="/pwt/css/ext6-pmx.css?ver=[% wtversion %]" />
     [% IF langfile %]
     <script type='text/javascript' src='/pve2/locale/pmg-lang-[% lang %].js'></script>
     [% ELSE %]
@@ -33,12 +33,12 @@
         CSRFPreventionToken: '[% token %]'
       };
     </script>
-    <script type="text/javascript" src="/proxmoxlib.js"></script>
+    <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>
     <script type="text/javascript" src="/pve2/ext6/locale/locale-[% lang %].js"></script>
     <script type="text/javascript">
       Ext.History.fieldid = 'x-history-field';
     </script>
-    <script type="text/javascript" src="/pve2/js/pmgmanagerlib.js"></script>
+    <script type="text/javascript" src="/pve2/js/pmgmanagerlib.js?ver=[% version %]"></script>
   </head>
   <body>
     <!-- Fields required for history management -->
-- 
2.20.1




More information about the pmg-devel mailing list