How data is loaded and cached
APIs: All data is loaded via the FleekDash REST API under /wp-json/fleekdash/v1/analytics/: visitors, pageviews, kpi-summary, real-time, popular-posts, user-registrations, recent-users, referrers, devices, geographic. Export and cache endpoints (e.g. cache/stats, cache/clear, cache/warm) exist for admins and automation.
Authentication: Requests use the platform apiClient, so authentication (e.g. nonce) is handled automatically; no need to configure tokens in the UI.
React Query: The frontend uses React Query (TanStack Query) for all analytics requests. Query keys include the endpoint and params (e.g. time range), so data is cached and deduplicated. Changing the time range or toggling Live creates new or updated queries.
Backend caching: The backend can cache analytics results (e.g. via AnalyticsCacheService). Cache TTL and invalidation depend on server configuration. The dashboard stays fast when switching periods or revisiting the page.
Stale-while-revalidate: React Query's default behavior (stale time, refetch on window focus, etc.) applies, so you may see cached data first and then updated data after a refetch.
Benefit: Predictable, fast loading and the option to clear or warm cache when needed.