exists($path)){ return response()->json(['error' => 'Image not found'], 404); } $fullPath = Storage::disk('local')->path($path); $lastModified = filemtime($fullPath); return response()->file($fullPath, [ 'Content-Type' => 'image/png', 'Cache-Control' => 'public, max-age='.$cacheLimit, // 24 hours 'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified) . ' GMT', 'ETag' => md5($path . $lastModified), ]); } }