From 7e49a259f4ab69bd8fd7d42bf7dcc1046266a12e Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 19 Feb 2024 12:30:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(frontend)=20add=20stale=20ca?= =?UTF-8?q?che?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We add a stale cache to reduce the number of requests to the server. This will help to improve the performance of the application. --- src/frontend/apps/desk/src/pages/AppProvider.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/frontend/apps/desk/src/pages/AppProvider.tsx b/src/frontend/apps/desk/src/pages/AppProvider.tsx index e59485f0e..16b932994 100644 --- a/src/frontend/apps/desk/src/pages/AppProvider.tsx +++ b/src/frontend/apps/desk/src/pages/AppProvider.tsx @@ -6,7 +6,20 @@ import { useCunninghamTheme } from '@/cunningham'; import { Auth } from '@/features/auth/Auth'; import '@/i18n/initI18n'; -const queryClient = new QueryClient(); +/** + * QueryClient: + * - defaultOptions: + * - staleTime: + * - global cache duration - we decided 3 minutes + * - It can be overridden to each query + */ +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: 1000 * 60 * 3, + }, + }, +}); export default function AppProvider({ children,