300) { @file_put_contents($lock, (string)time()); @exec('nohup /var/www/html/api/handlers/l99-honest-refresh.sh > /dev/null 2>&1 &'); } // Return stale cache if exists, or "computing" status if (file_exists($cache)) { $data = @json_decode(file_get_contents($cache), true); $data['cache_age_sec'] = time() - filemtime($cache); $data['status'] = 'stale_cache_refreshing'; echo json_encode($data, JSON_PRETTY_PRINT); } else { echo json_encode([ 'ok' => false, 'status' => 'computing_first_run', 'check_in_sec' => 90, 'message' => 'First run computing, wait ~90s and retry' ]); }