diff --git a/api/routers/config.py b/api/routers/config.py index 24de56c..3a9e5d5 100644 --- a/api/routers/config.py +++ b/api/routers/config.py @@ -24,6 +24,9 @@ _version_cache: dict = { "check_failed": False, } +# Cache TTL in seconds (24 hours) +VERSION_CACHE_TTL = 24 * 60 * 60 + def get_version() -> str: """Read version from pyproject.toml""" @@ -48,11 +51,16 @@ def get_latest_version_cached(current_version: str) -> tuple[Optional[str], bool """ global _version_cache - # Use cache if available (lives for entire API process lifetime) - if _version_cache["timestamp"] > 0: - logger.debug("Using cached version check result") + # Check if cache is still valid (within TTL) + cache_age = time.time() - _version_cache["timestamp"] + if _version_cache["timestamp"] > 0 and cache_age < VERSION_CACHE_TTL: + logger.debug(f"Using cached version check result (age: {cache_age:.0f}s)") return _version_cache["latest_version"], _version_cache["has_update"] + # Cache expired or not yet set + if _version_cache["timestamp"] > 0: + logger.info(f"Version cache expired (age: {cache_age:.0f}s), refreshing...") + # Perform version check with strict error handling try: logger.info("Checking for latest version from GitHub...") diff --git a/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx b/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx index d759fce..7916eae 100644 --- a/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx +++ b/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx @@ -63,7 +63,7 @@ export function SystemInfo() {