feat: optimize Proxmox statistics loading by preloading data on mount and reducing cache TTL for faster updates

This commit is contained in:
2025-12-01 12:14:10 -05:00
parent bbe6231328
commit 0c4a8f764d
2 changed files with 24 additions and 7 deletions

View File

@@ -139,6 +139,10 @@ class Statistics extends Component
$this->networkAnalysis['topPorts'] = [];
$this->networkAnalysis['security'] = [];
}
// Preload graph data on mount to speed up initial display
// This runs in the background while the page is rendering
$this->dispatch('proxmox:stats');
}
#[On('proxmox:stats')]
@@ -501,7 +505,8 @@ class Statistics extends Component
$cacheKey = 'proxmox-stats-' . $this->server->id . '-' . $graphType . '-' . $timeRange . '-' . $aggregation;
try {
$data = Cache::remember($cacheKey, 60, function () use ($timeRange, $aggregation) {
// Reduced cache TTL from 60 to 30 seconds for fresher data and faster updates
$data = Cache::remember($cacheKey, 30, function () use ($timeRange, $aggregation) {
$proxmox = new Proxmox;
$stats = $proxmox->request('/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/rrddata', data: [
'timeframe' => $timeRange,