'inline', 'X-Content-Type-Options' => 'nosniff', ]; $response = $disk->response($path, null, $headers); $modified = (int) $disk->lastModified($path); $size = (int) $disk->size($path); $response->setEtag(md5($path.'|'.$modified.'|'.$size)); $response->setLastModified(Carbon::createFromTimestamp($modified)); if ($versioned) { $response->headers->set('Cache-Control', $scope.', max-age=31536000, immutable'); } else { $response->headers->set('Cache-Control', $scope.', max-age=0, must-revalidate'); } $response->isNotModified($request); return $response; } /** Pfad der angefragten Größe (`?g=klein|mittel`), sonst die Hauptdatei. */ protected function imagePathFor(Request $request, string $diskName, string $path): string { $size = $request->query('g'); $resolved = ImageVariants::resolve(Storage::disk($diskName), $path, is_string($size) ? $size : null); // Bestand ohne Fassungen: Die Hauptdatei geht hinaus, und die Warteschlange legt die Fassungen an (der Web-Prozess // schreibt nie). Höchstens einmal je Tag und Bild; ist die Quelle schmaler als die Stufe, bleibt es bei der Hauptdatei. if ($resolved === $path && ImageVariants::isSize($size) && Cache::add('bildvarianten.'.md5($path), true, now()->addDay())) { DeriveImageVariants::dispatch($path); } return $resolved; } /** `?v=` ist da und eine einfache Zahl (Zeitstempel). */ protected function hasImageVersion(Request $request): bool { $version = $request->query('v'); return is_string($version) && preg_match('/^[0-9]{1,12}$/', $version) === 1; } }