From 04ac3be242635cebae6bfbad85518357a1e48115 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 2 Mar 2025 17:44:53 +0100 Subject: [PATCH] adjust cache --- interface/src/api/endpoints.ts | 2 +- interface/src/api/system.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/api/endpoints.ts b/interface/src/api/endpoints.ts index cbc0a4bca..d3b2a4c93 100644 --- a/interface/src/api/endpoints.ts +++ b/interface/src/api/endpoints.ts @@ -9,7 +9,7 @@ export const ACCESS_TOKEN = 'access_token'; export const alovaInstance = createAlova({ statesHook: ReactHook, // timeout: 3000, // 3 seconds before throwing a timeout error, default is 0 = none - cacheFor: null, // disable cache + // cacheFor: null, // disable cache // cacheFor: { // GET: { // mode: 'memory', diff --git a/interface/src/api/system.ts b/interface/src/api/system.ts index 387fddcc3..99162e20f 100644 --- a/interface/src/api/system.ts +++ b/interface/src/api/system.ts @@ -14,8 +14,10 @@ export const updateLogSettings = (data: LogSettings) => export const fetchLogES = () => alovaInstance.Get('/es/log'); // Get versions from GitHub +// cache for 10 minutes to stop getting the IP blocked by GitHub export const getStableVersion = () => alovaInstanceGH.Get('latest', { + cacheFor: 60 * 10 * 1000, transform(response: { data: { name: string; published_at: string } }) { return { name: response.data.name.substring(1), @@ -25,6 +27,7 @@ export const getStableVersion = () => }); export const getDevVersion = () => alovaInstanceGH.Get('tags/latest', { + cacheFor: 60 * 10 * 1000, transform(response: { data: { name: string; published_at: string } }) { return { name: response.data.name.split(/\s+/).splice(-1)[0].substring(1),