isValidService($service)) { return response('Not Found', 404); } // Generate if doesn't exist if (! $ogService->exists($service)) { $ogService->generate($service); } // Get the image content $filename = "og-images/services/{$service}.png"; if (! Storage::disk('public')->exists($filename)) { return response('Not Found', 404); } $content = Storage::disk('public')->get($filename); $lastModified = Storage::disk('public')->lastModified($filename); return response($content, 200, [ 'Content-Type' => 'image/png', 'Content-Length' => strlen($content), 'Cache-Control' => 'public, max-age='.self::CACHE_TTL.', immutable', 'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified).' GMT', 'ETag' => '"'.md5($content).'"', 'X-Content-Type-Options' => 'nosniff', ]); } }