पाठ 27 / 29
PWAs को Deploy करना
अपने PWA को production में deploy करें proper caching headers और version management के साथ।
Deployment Considerations
हमेशा HTTPS पर deploy करें। Cache headers set करें: HTML के लिए no-cache, versioned assets के लिए long cache। Service worker versioning और update checks का उपयोग करें। Fast delivery के लिए CDN को configure करें।
Cache header configuration (Nginx)
Production में अलग-अलग file types के लिए proper cache headers।
# Cache static assets for 1 year
location ~* \.(js|css|png|jpg|svg)$ {
expires 365d;
add_header Cache-Control "public, immutable";
}
# Never cache HTML
location ~* \.html$ {
expires -1;
add_header Cache-Control "public, no-cache";
}
# Service worker - short cache
location = /sw.js {
expires 1d;
add_header Cache-Control "public, max-age=86400";
}
# Manifest - short cache
location = /manifest.json {
expires 1h;
add_header Cache-Control "public, max-age=3600";
}
Output:
Proper cache headers configured for PWA asset types.
एक आम गलती
Service worker files या manifest.json को कभी cache न करें। Short expiry times (1 घंटा) का उपयोग करें ताकि updates को जल्दी pick up किया जा सके।