पाठ 20 / 25

सर्विस वर्कर्स और ऑफ़लाइन समर्थन

ऑफ़लाइन समर्थन, तत्काल लोडिंग और बेहतर लचीलापन के लिए सर्विस वर्कर्स लागू करें।

सर्विस वर्कर जीवन चक्र

Register with navigator.serviceWorker.register(). Lifecycle: install (cache assets), activate (clean old cache), fetch (intercept requests). Supports offline with cached responses, instant repeat visits with cache-first strategy.

सर्विस वर्कर्स के साथ कैशिंग रणनीतियां

Cache First: return cache if available, fallback to network. Network First: try network, fallback to cache. Stale-While-Revalidate: serve cache immediately, update in background. Choose strategy per resource type.

सर्विस वर्कर सर्वोत्तम प्रथाएं

Scope carefully to avoid unexpected behavior. Version caches to enable updates. Use self-closing versions for deployments. Monitor updates in analytics. Test offline mode regularly.

त्वरित जाँच

त्वरित जाँच: Cache First रणनीति क्या है?

  • यदि उपलब्ध हो तो कैश लौटाएं, अन्यथा नेटवर्क का उपयोग करें
  • हमेशा नेटवर्क से पहले लाएं
  • कैशिंग को अक्षम करें
Answer