From 85381f60a0b89829a7cdf2deabb7afb495fdc6f4 Mon Sep 17 00:00:00 2001 From: jgor20 <102353650+jgor20@users.noreply.github.com> Date: Sun, 11 Jan 2026 15:01:00 +0000 Subject: [PATCH] fix(ui): add TTL check for cache expiration Add a 24-hour time-to-live check to the data cache restoration logic to prevent using stale cached data. This ensures data freshness by expiring and removing outdated cache entries before restoration. Also corrected a minor typo in the validity check comment. --- public/js/data-store.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/js/data-store.js b/public/js/data-store.js index 5a981b9..746e2da 100644 --- a/public/js/data-store.js +++ b/public/js/data-store.js @@ -50,7 +50,16 @@ document.addEventListener('alpine:init', () => { const cached = localStorage.getItem('ag_data_cache'); if (cached) { const data = JSON.parse(cached); - // Basic validty check + const CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours + + // Check TTL + if (data.timestamp && (Date.now() - data.timestamp > CACHE_TTL)) { + console.log('Cache expired, skipping restoration'); + localStorage.removeItem('ag_data_cache'); + return; + } + + // Basic validity check if (data.accounts && data.models) { this.accounts = data.accounts; this.models = data.models;