From bc54c7400653bf34dcff4342e4f45c4123af5a1f Mon Sep 17 00:00:00 2001
From: Roj234 <82699138+roj234@users.noreply.github.com>
Date: Wed, 1 Apr 2026 00:03:43 +0800
Subject: [PATCH 1/3] Implement version data caching mechanism
Add caching for version data to reduce API calls.
---
src_assets/common/assets/web/index.html | 38 +++++++++++++++++++++----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/src_assets/common/assets/web/index.html b/src_assets/common/assets/web/index.html
index 7a02b34fc36..50932b65cf1 100644
--- a/src_assets/common/assets/web/index.html
+++ b/src_assets/common/assets/web/index.html
@@ -187,11 +187,39 @@
{{ githubVersion.release.name }}
this.platform = config.platform;
this.controllerEnabled = config.controller !== "disabled";
this.version = new SunshineVersion(null, config.version);
- console.log("Version: ", this.version.version)
- this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()), null);
- console.log("GitHub Version: ", this.githubVersion.version)
- this.preReleaseVersion = new SunshineVersion((await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then((r) => r.json())).find(release => release.prerelease), null);
- console.log("Pre-Release Version: ", this.preReleaseVersion.version)
+ console.log("Version: ", this.version.version);
+
+ const now = Date.now();
+ let { lastCheck, latest, pre } = JSON.parse(localStorage.getItem('sunshine_version_cache') || '{}');
+ const oneDay = 24 * 60 * 60 * 1000;
+
+ if (lastCheck && (now - lastCheck < oneDay) && latest) {
+ console.log("Using cached version data (within 24h cooldown)");
+ this.githubVersion = new SunshineVersion(latest, null);
+ if (pre) {
+ this.preReleaseVersion = new SunshineVersion(pre, null);
+ }
+ } else {
+ this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()), null);
+ console.log("GitHub Version: ", this.githubVersion.version)
+
+ let preReleaseJson = null;
+ // Only send request when need pre-release
+ if (this.notifyPreReleases) {
+ const releases = await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then(e => e.json());
+ preReleaseJson = releases.find(e => e.prerelease);
+ if (preReleaseJson) {
+ this.preReleaseVersion = new SunshineVersion((await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then((r) => r.json())).find(release => release.prerelease), null);
+ console.log("Pre-Release Version: ", this.preReleaseVersion.version)
+ }
+ }
+
+ localStorage.setItem('sunshine_version_cache', JSON.stringify({
+ lastCheck: now,
+ latest: latestJson,
+ pre: preReleaseJson
+ }));
+ }
// Fetch ViGEmBus status only on Windows when controller is enabled
if (this.platform === 'windows' && this.controllerEnabled) {
From 05f47994247658f4b03fa7247e0a4e37a0d4936d Mon Sep 17 00:00:00 2001
From: Roj234 <82699138+roj234@users.noreply.github.com>
Date: Wed, 1 Apr 2026 00:05:39 +0800
Subject: [PATCH 2/3] fix
---
src_assets/common/assets/web/index.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src_assets/common/assets/web/index.html b/src_assets/common/assets/web/index.html
index 50932b65cf1..1a602cc1e5c 100644
--- a/src_assets/common/assets/web/index.html
+++ b/src_assets/common/assets/web/index.html
@@ -200,7 +200,8 @@ {{ githubVersion.release.name }}
this.preReleaseVersion = new SunshineVersion(pre, null);
}
} else {
- this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()), null);
+ const latestJson = await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then(e => e.json());
+ this.githubVersion = new SunshineVersion(latestJson, null);
console.log("GitHub Version: ", this.githubVersion.version)
let preReleaseJson = null;
From ed271ebd887976f416d0239c942a1f8b4d1ee82a Mon Sep 17 00:00:00 2001
From: Roj234 <82699138+roj234@users.noreply.github.com>
Date: Thu, 2 Apr 2026 21:07:54 +0800
Subject: [PATCH 3/3] Change cache duration from 24h to 1h
---
src_assets/common/assets/web/index.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src_assets/common/assets/web/index.html b/src_assets/common/assets/web/index.html
index 1a602cc1e5c..0f7884b925c 100644
--- a/src_assets/common/assets/web/index.html
+++ b/src_assets/common/assets/web/index.html
@@ -191,10 +191,10 @@ {{ githubVersion.release.name }}
const now = Date.now();
let { lastCheck, latest, pre } = JSON.parse(localStorage.getItem('sunshine_version_cache') || '{}');
- const oneDay = 24 * 60 * 60 * 1000;
+ const cacheAge = 60 * 60 * 1000;
- if (lastCheck && (now - lastCheck < oneDay) && latest) {
- console.log("Using cached version data (within 24h cooldown)");
+ if (lastCheck && (now - lastCheck < cacheAge) && latest) {
+ console.log("Using cached version data");
this.githubVersion = new SunshineVersion(latest, null);
if (pre) {
this.preReleaseVersion = new SunshineVersion(pre, null);