From 38e841d8010edcb707c251237d2396861a47f08b Mon Sep 17 00:00:00 2001 From: LightZirconite Date: Sun, 9 Nov 2025 23:18:14 +0100 Subject: [PATCH] feat: Add cache-busting to package.json request to prevent stale responses --- setup/update/update.mjs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/setup/update/update.mjs b/setup/update/update.mjs index f41f0ab..c8e331c 100644 --- a/setup/update/update.mjs +++ b/setup/update/update.mjs @@ -283,13 +283,26 @@ async function checkVersion() { const repoOwner = 'Obsidian-wtf' const repoName = 'Microsoft-Rewards-Bot' const branch = 'main' - const pkgUrl = `https://raw.githubusercontent.com/${repoOwner}/${repoName}/refs/heads/${branch}/package.json` + + // Add cache-buster to prevent GitHub from serving stale cached version + const cacheBuster = Date.now() + const pkgUrl = `https://raw.githubusercontent.com/${repoOwner}/${repoName}/refs/heads/${branch}/package.json?cb=${cacheBuster}` console.log('🔍 Checking for updates...') console.log(` Local: ${localVersion}`) return new Promise((resolve) => { - const request = httpsGet(pkgUrl, (res) => { + // Request with cache-busting headers + const options = { + headers: { + 'Cache-Control': 'no-cache, no-store, must-revalidate', + 'Pragma': 'no-cache', + 'Expires': '0', + 'User-Agent': 'Microsoft-Rewards-Bot-Updater' + } + } + + const request = httpsGet(pkgUrl, options, (res) => { if (res.statusCode !== 200) { console.log(` ⚠️ Could not check remote version (HTTP ${res.statusCode})`) resolve({ updateAvailable: false, localVersion, remoteVersion: 'unknown' })