How the dashboard stores and refreshes data
Enterprise dashboard store
The dashboard uses a global store (e.g. Zustand) that holds:
Current preset (e.g. 7d, 30d, 90d, 1y) and optional custom date range.
Unified data: chart_data, KPIs (published_content, user_engagement, user_registrations), metadata (period, total_days, cache expiry, last_updated).
Cache per preset (and optionally per custom range) with TTL (e.g. 5 min for 7d, 15 min for 30d, 30 min for 90d, 1 hour for 1y).
Presets define: number of days, period (daily/weekly/monthly), cache TTL, and priority. This allows preloading and fast switching.
Preload
On init, the dashboard can preload data for presets (e.g. 7d, 30d, 90d, 1y) in the background so that when you switch preset or date range, data is already in memory or cache.
Preload is triggered by initializeDashboardPreload() and configured in the useEnterpriseDashboard hook (e.g. enableAutoPreload, preloadPresets).
Clear Cache (summary)
When you click Clear Cache:
Dashboard-related keys in localStorage and sessionStorage are removed.
The enterprise store cache is cleared (clearAllCache).
Any optimized data cache for the dashboard is cleared.
Pending posts cache is invalidated (invalidatePendingPostsCache).
React Query is invalidated for posts and post-stats.
Date range is reset to the last 30 days and saved to session storage.
Optionally, a backend cache-clear endpoint is called (e.g. /wp-json/fleekdash/v1/cache/clear-transients).
A full refresh of dashboard data is triggered and custom events (fleekdash:force-refresh-all-data, fleekdash:force-refresh-unified-dashboard) are dispatched so widgets reload.
Benefit: One action to get a clean slate and up-to-date numbers after big changes or if something looks wrong.