Todos los lenguajes y frameworks
Fastly Compute (JavaScript) JavaScript
Un fragmento en JavaScript para Fastly Compute (JavaScript) que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.
Fastly Compute (JavaScript) JavaScript
/// <reference types="@fastly/js-compute" />
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));
addEventListener('fetch', (event) => event.respondWith(handleRequest(event)));
function handleRequest(event) {
if (new URL(event.request.url).pathname !== '/pixel.gif') {
return new Response('Not Found', { status: 404 });
}
return new Response(GIF, {
headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
});
}
Ejecutamos este fragmento y comparamos los bytes que devolvió.
Comprobar
curl -sI http://localhost:8080/pixel.gif
Sitio oficial: Fastly Compute (JavaScript)