Browse Source

Merge pull request #3331 from Budibase/fix/browser-caching

bust cache when app versions are different
pull/3348/head
Martin McKeaveney 5 years ago
committed by GitHub
parent
commit
a2ed22a1e8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/server/src/api/controllers/application.js
  2. 2
      packages/server/src/api/controllers/static/index.js
  3. 9
      packages/server/src/utilities/index.js

2
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),
}
}

2
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`)

9
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`
}

Loading…
Cancel
Save