Fastly Compute (JavaScript) JavaScript
Fastly Compute (JavaScript) માટે JavaScript સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
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' },
});
}
અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.
ચકાસો
curl -sI http://localhost:8080/pixel.gif
સત્તાવાર સાઇટ: Fastly Compute (JavaScript)