पाठ 6 / 25

कैशिंग रणनीतियां

दोहराए जाने वाले दौरों पर HTTP कैशिंग, सर्विस वर्कर्स और कैश हेडर का उपयोग करके सामग्री तेजी से परोसें।

HTTP कैश हेडर

Use Cache-Control: public, max-age=31536000 for static assets. Set short TTL (e.g., 1 hour) for HTML. Add ETag or Last-Modified for cache validation. Example: Cache-Control: max-age=3600, must-revalidate.

CDN और एज कैशिंग

Store static assets on geographically distributed servers. CDN reduces latency by serving from closest location. Use cache purging to instantly invalidate stale content when deployments happen.

सर्विस वर्कर्स के साथ क्लाइंट-साइड कैशिंग

Intercept network requests and serve cached versions offline. Use cache strategies: Cache First (for static), Network First (for dynamic), Stale-While-Revalidate (serve stale, update in background).

कैश अमान्यता रणनीतियां

Use content hashing in filenames (app.a1b2c3d.js) for cache busting. Immediately invalidate on deploy. Monitor cache hit rates (target >90%). Balance between aggressiveness and freshness.

त्वरित जाँच

त्वरित जाँच: स्टेटिक संपत्ति के लिए अच्छा कैश TTL क्या है?

  • 1 साल (31536000 सेकंड)
  • 1 घंटा
  • कोई कैशिंग नहीं
Answer