Posts

Showing posts from September, 2024

Fetch Timeouts and Retries: Make Read Requests Predictable

Practical Web Development — Lesson 6 of 10 · Intermediate A loading spinner needs an exit path. A network request can stall, fail before a response arrives or return an HTTP error. This tutorial adds a per-attempt timeout and at most one retry for a read-only JSON request. It deliberately does not retry writes such as enrolment payments or progress changes. Build a bounded read helper Put this function in a browser module. Call it with a public same-origin JSON endpoint. A local test server with a delayed endpoint is useful for exercising timeout behaviour. async function readJson(url, timeoutMs = 5000) { for (let attempt = 0; attempt < 2; attempt++) { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), timeoutMs); let retry = false; try { const response = await fetch(url, { signal: controller.signal }); if (!response.ok) { const error = new Error('HTTP ' + response.status); error.retry...

Internet vs World Wide Web: HTML and Multimedia Explained

Internet vs World Wide Web: the key difference The Internet is the network infrastructure that connects devices and networks. The World Wide Web is a service that uses that infrastructure to deliver linked pages and media through browsers. Email and other network services can use the Internet without being web pages. HTML describes page content, HTTP carries web requests and responses, and URLs identify resources. The History of the Internet ARPANET was an early packet-switching research network funded by ARPA. Its first connected hosts appeared in 1969. Research on connecting different networks later helped develop the Internet. The Internet Society history, written by Internet pioneers , explains this development and distinguishes ARPANET from separate RAND research on military survivability. Key milestones in the history of the internet include: 1969 : ARPANET's first message sent. 1989 : Tim Berners-Lee proposes the World Wide Web. 1991 : The first website goes live, laying the...