Problem Statement
Which modern technology replaced the deprecated Application Cache for offline web apps?
Explanation
Service Workers provide a more flexible, powerful, and reliable way to build offline-capable web apps compared to the old Application Cache. They act as a proxy between the browser and network, caching files, handling fetch events, and enabling background sync or push notifications.
Code Solution
SolutionRead Only
<!-- Register a service worker -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(() => {
console.log('Service Worker registered');
});
}
</script>