From 6e6052483cab5c33873314a80bb25d901694e31d Mon Sep 17 00:00:00 2001 From: 0xa0 Date: Wed, 22 Jul 2026 16:35:17 +0200 Subject: [PATCH] faster poll --- config.php | 1 + inc/footer.php | 2 +- index.php | 2 +- status.php | 17 ++++------------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/config.php b/config.php index 48a29ad..d33367f 100644 --- a/config.php +++ b/config.php @@ -1,5 +1,6 @@ - © · source · build: + © · build diff --git a/index.php b/index.php index f27070f..6925d6a 100644 --- a/index.php +++ b/index.php @@ -5,7 +5,7 @@

status

-
+
diff --git a/status.php b/status.php index 13da74d..b1366ed 100644 --- a/status.php +++ b/status.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/config.php'; $cacheFile = DATA_DIR . '/lanyard.json'; -$ttl = 15; +$ttl = 2; if (!function_exists('lanyard_refresh')) { function lanyard_refresh(string $cacheFile): void { @@ -21,12 +21,11 @@ if (!function_exists('lanyard_refresh')) { } } -$haveCache = is_file($cacheFile); -$stale = !$haveCache || (time() - filemtime($cacheFile) > $ttl); +$isPoll = realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__; +$stale = !is_file($cacheFile) || (time() - filemtime($cacheFile) > $ttl); -if ($stale && !$haveCache) { +if ($stale && ($isPoll || !is_file($cacheFile))) { lanyard_refresh($cacheFile); - $stale = false; } $data = json_decode(@file_get_contents($cacheFile), true)['data'] ?? null; @@ -83,11 +82,3 @@ $banner = $bannerHash -