diff --git a/shell/plugins/dashboard-store/actions.js b/shell/plugins/dashboard-store/actions.js index 8d0d629fbfe..3abebe4962c 100644 --- a/shell/plugins/dashboard-store/actions.js +++ b/shell/plugins/dashboard-store/actions.js @@ -695,7 +695,7 @@ export default { const res = await dispatch('request', { opt, type }); - await dispatch('load', { data: res }); + await dispatch('load', { data: res, invalidatePageCache: opt.invalidatePageCache }); if ( opt.watch !== false ) { dispatch('watch', createFindWatchArg({ diff --git a/shell/plugins/dashboard-store/resource-class.js b/shell/plugins/dashboard-store/resource-class.js index f60127470ad..3d22240cc49 100644 --- a/shell/plugins/dashboard-store/resource-class.js +++ b/shell/plugins/dashboard-store/resource-class.js @@ -1253,6 +1253,12 @@ export default class Resource { delete opt.replace; } + // Will loading this resource invalidate the resources in the cache that represent a page (resource is not from page) + // By default we set this to no, it won't pollute the cache. Most likely either + // 1. The resource came from a list already (loaded resource is already in the page that is in the cache) + // 2. UI is not on a page with a list (cache doesn't represent a list) + const invalidatePageCache = opt.invalidatePageCache || false; + try { const res = await this.$dispatch('request', { opt, type: this.type } ); @@ -1261,7 +1267,9 @@ export default class Resource { // Steve sometimes returns Table responses instead of the resource you just saved.. ignore if ( res && res.kind !== 'Table') { - await this.$dispatch('load', { data: res, existing: (forNew ? this : undefined ) }); + await this.$dispatch('load', { + data: res, existing: (forNew ? this : undefined ), invalidatePageCache + }); } } catch (e) { if ( this.type && this.id && e?._status === 409) { @@ -1269,7 +1277,14 @@ export default class Resource { await this.$dispatch('find', { type: this.type, id: this.id, - opt: { force: true } + opt: { + // We want to update the value in cache, so force the request + force: true, + // We're not interested in opening a watch for this specific resource + watch: false, + // Unless overridden, this will be false, we're probably from a list and we don't want to clear it's state + invalidatePageCache + } }); }