From ac5b3a38c5f0d743141718d268804f74d6b24683 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 10 Jun 2026 12:45:48 +0530 Subject: [PATCH] refactor: remove cold-path cache key preflight --- .../dashboard/api/CacheEnabledApiClient.js | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/app/javascript/dashboard/api/CacheEnabledApiClient.js b/app/javascript/dashboard/api/CacheEnabledApiClient.js index 26e73ed2f..ed4e6a3be 100644 --- a/app/javascript/dashboard/api/CacheEnabledApiClient.js +++ b/app/javascript/dashboard/api/CacheEnabledApiClient.js @@ -25,13 +25,6 @@ class CacheEnabledApiClient extends ApiClient { return axios.get(this.url); } - async getCacheKeyFromServer() { - const response = await axios.get( - `/api/v1/accounts/${this.accountIdFromRoute}/cache_keys` - ); - return response.data.cache_keys?.[this.cacheModelName] ?? null; - } - // eslint-disable-next-line class-methods-use-this extractDataFromResponse(response) { return response.data.payload; @@ -63,16 +56,10 @@ class CacheEnabledApiClient extends ApiClient { return this.marshallData(localData); } - // Empty IDB (first load or wiped): capture the authoritative key before - // persisting rows so future boots can revalidate this cached data. - let serverKey = null; - try { - serverKey = await this.getCacheKeyFromServer(); - } catch { - // Ignore error. The network fetch below should still work, and storing - // null keeps this cache eligible for boot-time revalidation later. - } - return this.refetchAndCommit(serverKey); + // Empty IDB (first load or wiped): fetch data without a cache key. The + // next pushed key map won't match the missing key and will refetch once, + // stamping the authoritative key — the client never pulls keys itself. + return this.refetchAndCommit(null); } async refetchAndCommit(newKey = null) { @@ -89,7 +76,7 @@ class CacheEnabledApiClient extends ApiClient { }); await this.dataManager.setCacheKeys({ - [this.cacheModelName]: newKey === undefined ? null : newKey, + [this.cacheModelName]: newKey, }); } catch { // Ignore error