Async JS: API fetch with a timeout
Category
HTTP, caching, CORS, WebSockets, HTTP/2 vs HTTP/3.
12 questions
Async JS: API fetch with a timeout
CORS, preflight requests, and SameSite cookies
Difference between fetch and axios
How do you fetch data in Next.js using getStaticProps and getServerSideProps
Cache-Control directs *how long* responses are cached. ETag/Last-Modified enable *revalidation* — client sends If-None-Match, server returns 304 if unchanged. Combine: long max-age for hashed assets, short max-age + revalidation for HTML/API.
If a user clicks a button multiple times to fetch data, how to cancel old API calls and use only the latest result
Implement fetch with a timeout/abort feature
WebSockets vs HTTP — and why aggressive polling is a bad idea
Polling is simplest (HTTP). SSE is one-way server→client (text, auto-reconnect, HTTP/2-friendly). WebSockets are bidirectional, binary-capable, lowest-latency. Pick the *least* powerful that fits — operational cost rises with each.
What is CORS and how does it work
What is RTK query ? How is it different from axios & fetch.
What is the use of Headers in HTTP requests