Offline Site
You'll add a manifest and a service worker so your site loads on a plane, then install it on your phone's home screen like an app.
About
A progressive web app is a normal site with two extra files: a manifest so phones can install it, and a service worker so it loads without a connection. A personal site with a few posts fits in a cache easily, and the visitors who read you on the train will notice. Keep it simple, which means caching the shell, caching the pages people visit, and showing something useful when they're offline. The last requirement matters more than it looks, because a service worker shipped once and forgotten can strand visitors on stale pages for a year.
At a glance
- Per requirement
- 25 XP
- Completion bonus
- 150 XP
- Requirements
- 6
- Takes
- Two weekends
- Skill level
- Intermediate (months of practice)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Add a web app manifest and icons. Set name, short_name, start_url, display and theme_color, and add icons at 192 and 512 px. Link the manifest in the head. Take a screenshot of the manifest in the Application panel of dev tools. Photo
-
2
Register a service worker that caches the shell. On install, cache the home page, the stylesheet and the offline page. Keep the script under 50 lines, and copy a known-good pattern while reading every line so you know what it does. Take a screenshot of the worker registered and the cache contents. Photo
-
3
Cache pages as people visit them. Go network first and fall back to the cache. Visit three pages, turn on airplane mode, and load them again. Film the offline load. Video
-
4
Build an offline page for anything that isn't cached. Plain text is fine: you're offline, here's what you can still read, with links to the cached pages. Take a screenshot of it showing in airplane mode. Photo
-
5
Install it on your phone's home screen. From the browser menu, choose add to home screen, then open the site from its icon. Take a photo of the icon on your home screen and the site open, or film yourself tapping the icon and the site opening. Photo or video
-
6
Ship an update and confirm the old cache clears. Change the cache name, deploy, and reload twice, and the old content should be gone. Plenty of people ship a service worker once and strand their visitors on stale pages for a year. Take a screenshot of the new cache name in the Application panel. Photo