performance: Caching, deferred Tracking & externe Timeouts (H7, M12, M13)
- Navigations-Chrome (CategoryNavigation), Suche- und Newsroom-Seitendaten 300s gecacht; gemeinsamer WebPageCache-Helper (eine TTL/Key-Konvention). - Cache-Poisoning über ?page= geschlossen (Key an Paginator ausgerichtet, kein withQueryString im Cache); Newsrooms cachet nur den ungefilterten Fall und die ersten Seiten (kein unbegrenzter Key-Raum). - Detailseiten schreiben Hits/View-Events deferred nach der Response (M12); OpenAI-/Markt-/USt-ID-Aufrufe mit Connect-Timeouts und begrenzten Retries; Admin-Memo-Caches konsistent invalidiert. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1afcc364ac
commit
22975e762e
18 changed files with 419 additions and 39 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Services\Web;
|
|||
|
||||
use App\Models\PressRelease;
|
||||
use App\Scopes\PortalScope;
|
||||
use App\Support\WebPageCache;
|
||||
use App\Support\WebPortalContext;
|
||||
|
||||
/**
|
||||
|
|
@ -17,20 +18,28 @@ class SuchePageData
|
|||
*/
|
||||
public function build(WebPortalContext $context): array
|
||||
{
|
||||
$mostReadReleases = PressRelease::query()
|
||||
->withoutGlobalScope(PortalScope::class)
|
||||
->forPortalValues($context->portalValues)
|
||||
->forLanguage($context->language)
|
||||
->visibleInArchive()
|
||||
->orderByDesc('hits')
|
||||
->orderByDesc('published_at')
|
||||
->limit(5)
|
||||
->get(['id', 'slug', 'title', 'hits', 'portal', 'language']);
|
||||
$cacheKey = WebPageCache::key('search', [
|
||||
'most-read',
|
||||
implode('-', $context->portalValues),
|
||||
$context->language,
|
||||
]);
|
||||
|
||||
return [
|
||||
'portal' => $context->portal->value,
|
||||
'language' => $context->language,
|
||||
'mostReadReleases' => $mostReadReleases,
|
||||
];
|
||||
return WebPageCache::remember($cacheKey, static function () use ($context): array {
|
||||
$mostReadReleases = PressRelease::query()
|
||||
->withoutGlobalScope(PortalScope::class)
|
||||
->forPortalValues($context->portalValues)
|
||||
->forLanguage($context->language)
|
||||
->visibleInArchive()
|
||||
->orderByDesc('hits')
|
||||
->orderByDesc('published_at')
|
||||
->limit(5)
|
||||
->get(['id', 'slug', 'title', 'hits', 'portal', 'language']);
|
||||
|
||||
return [
|
||||
'portal' => $context->portal->value,
|
||||
'language' => $context->language,
|
||||
'mostReadReleases' => $mostReadReleases,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue