Integrate · 08
PWA and web push
The storefront installs as a lightweight PWA and can send browser push notifications. Both features are optional and fail closed when the keys or browser permission are missing.
PWA shell
The manifest is served at /manifest.json; the service worker is served at /service-worker.js; an offline page is available at /offline/. The manifest uses the brand name, short name, theme colours and icons from the house settings.
| File | Path |
|---|---|
| Manifest | /manifest.json |
| Service worker | /service-worker.js |
| Offline page | /offline/ |
| Push public key | /push/public-key/ |
VAPID keys
Generate a key pair with the management command, then store the public and private keys in .env. The subject should be a contact URL or mailto address. Restart the service after changing the keys; existing browser subscriptions signed with the old key will need to resubscribe.
python manage.py generate_vapid_keys
VAPID_PUBLIC_KEY=...
VAPID_PRIVATE_KEY=...
VAPID_SUBJECT=mailto:care@perfumz.com
sudo systemctl restart perfumzChanging the VAPID key pair invalidates existing subscriptions. Do it deliberately and send a re-subscribe prompt.
Browser subscriptions
The storefront asks for notification permission, fetches the public key, subscribes through the service worker and posts the subscription to /push/subscribe/. Unsubscribe is available at /push/unsubscribe/. Staff can compose a push at /dashboard/push/.
Testing push
# Send a test push to a subscribed staff/customer account
python manage.py send_push_notification --help
# Check the manifest and service worker
curl -fsS https://perfumz.com/manifest.json
curl -fsS https://perfumz.com/service-worker.js | head -30Browser push requires HTTPS (except localhost), a supported browser and explicit permission. If nothing arrives, check the browser permission, the VAPID pair, the subscription record and the service log.
Offline behaviour
The service worker caches the shell and serves the offline page when the network is unavailable. Checkout and account actions require the network; do not imply that an offline order was submitted. Test the offline page by disabling the network after the first load.