Interview Question

What is service worker?

A service worker can control caching and offline behavior.

💡 Concept ✅ Quick Revision 🌐 HTML

Answer

A service worker is a script that runs separately from the web page. • It can handle network requests and cache files. • It helps pages work offline or load faster. • It requires HTTPS on normal websites.

💡 Simple Example

<p>navigator.serviceWorker.register(&#039;/sw.js&#039;);</p>

⚡ Quick Revision

A service worker can control caching and offline behavior.