validated('lang') ?? app()->getLocale(); $etag = $this->glossaries->etag($kind, $lang); $withEtag = fn ($response) => $etag === null ? $response : $response ->setEtag($etag) ->header('Cache-Control', 'public, no-cache'); // 表没变:在查整表之前就回 304(isNotModified 按 RFC 9110 弱比较,nginx 压缩后的 W/"…" 也认) if ($etag !== null) { $probe = $withEtag(new Response); if ($probe->isNotModified($request)) { return $probe; } } $result = $this->glossaries->entries($kind, $lang); return $withEtag(GlossaryEntryResource::collection($result['items'])->additional(['meta' => [ 'kind' => $kind, 'lang' => $result['lang'], 'total' => $result['items']->count(), ]])->response()); } }