Laravel PHP
ตัวอย่างโค้ด PHP สำหรับ Laravel ที่ตอบคำขอไปยัง /pixel.gif ด้วย GIF ว่าง ซึ่งถอดรหัสเพียงครั้งเดียวตอนเริ่มทำงาน
Laravel PHP
<?php
// routes/web.php
use Illuminate\Support\Facades\Route;
Route::get('/pixel.gif', function () {
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
return response($gif, 200, [
'Content-Type' => 'image/gif',
'Content-Length' => strlen($gif),
'Cache-Control' => 'no-store',
]);
});
เรารันตัวอย่างโค้ดนี้และเทียบไบต์ที่ได้กลับมาแล้ว
ตรวจสอบ
curl -sI http://localhost:8080/pixel.gif