Todos los lenguajes y frameworks
Plain PHP (php-fpm, mod_php, php -S) PHP
Un fragmento en PHP para Plain PHP (php-fpm, mod_php, php -S) que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.
Plain PHP (php-fpm, mod_php, php -S) PHP
<?php
// Front controller: works under php-fpm, Apache mod_php or the built-in server.
if (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) !== '/pixel.gif') {
http_response_code(404);
return;
}
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
header('Content-Type: image/gif');
header('Content-Length: ' . strlen($gif));
header('Cache-Control: no-store');
echo $gif;
Ejecutamos este fragmento y comparamos los bytes que devolvió.
Comprobar
curl -sI http://localhost:8080/pixel.gif
Sitio oficial: Plain PHP (php-fpm, mod_php, php -S)