From 2a2963dac49eb4ce42a9162230f48bec5113ceec Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 11 Nov 2021 12:21:45 +0100 Subject: [PATCH 1/2] bust cache when app versions are different --- packages/server/src/api/controllers/static/index.js | 2 +- packages/server/src/utilities/index.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index cc463aefdb..51fc2df3e0 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -87,7 +87,7 @@ exports.serveApp = async function (ctx) { title: appInfo.name, production: env.isProd(), appId, - clientLibPath: clientLibraryPath(appId), + clientLibPath: clientLibraryPath(appId, appInfo.version), }) const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`) diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index e568ba063c..39e339a126 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -51,11 +51,16 @@ exports.objectStoreUrl = () => { * @return {string} The URL to be inserted into appPackage response or server rendered * app index file. */ -exports.clientLibraryPath = appId => { +exports.clientLibraryPath = (appId, version) => { if (env.isProd()) { - return `${exports.objectStoreUrl()}/${sanitizeKey( + let url = `${exports.objectStoreUrl()}/${sanitizeKey( appId )}/budibase-client.js` + // append app version to bust the cache + if (version) { + url += `?v=${version}` + } + return url } else { return `/api/assets/client` } From 125610f5a115e323a44c54b675c9e80ac748b63c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 11 Nov 2021 12:29:52 +0100 Subject: [PATCH 2/2] update clientLibraryPath call in application.js --- packages/server/src/api/controllers/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 4ea308a790..2665ff0104 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -197,7 +197,7 @@ exports.fetchAppPackage = async ctx => { application, screens, layouts, - clientLibPath: clientLibraryPath(ctx.params.appId), + clientLibPath: clientLibraryPath(ctx.params.appId, application.version), } }