update: fix node etag

This commit is contained in:
v2board 2023-01-04 23:02:28 +08:00
parent 63566fbd2c
commit 0c935c5e3e
2 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,7 @@ class ServerController extends Controller
$serverService = new ServerService();
$servers = $serverService->getAvailableServers($user);
}
$eTag = sha1(json_encode(array_column($servers, 'is_online', 'updated_at')));
$eTag = sha1(json_encode(array_column($servers, 'cache_key')));
if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
abort(304);
}

View File

@ -104,6 +104,7 @@ class ServerService
$servers = array_map(function ($server) {
$server['port'] = (int)$server['port'];
$server['is_online'] = (time() - 300 > $server['last_check_at']) ? 0 : 1;
$server['cache_key'] = "{$server['type']}-{$server['id']}-{$server['updated_at']}-{$server['is_online']}";
return $server;
}, $servers);
return $servers;