A Node.js/Express example demonstrating Skybolt's asset caching.
make install
make build
make serve
# Visit http://localhost:8086- First Visit: Assets are inlined directly in the HTML with
sb-assetattributes - Service Worker: Registers and caches the inlined assets via Cache API
- Repeat Visit: Assets served from Service Worker cache (~5ms response time)
- Cache Invalidation: Rebuild with
npm run buildto auto-invalidate stale assets
node-express/
├── src/
│ ├── css/
│ │ ├── critical.css # Above-the-fold styles (blocking)
│ │ └── main.css # Below-the-fold styles (async)
│ └── js/
│ └── app.js # Client application
├── dist/ # Built assets (generated)
├── server.js # Express application
├── vite.config.js # Vite + Skybolt plugin config
├── package.json
├── Makefile
├── Dockerfile
└── docker-compose.yml
- Vite builds assets with content hashes
- Skybolt plugin generates
dist/.skybolt/render-map.json - Render map contains asset URLs, hashes, and full content
const skybolt = new Skybolt('./dist/.skybolt/render-map.json', req.cookies)
// Returns inlined <style> with sb-asset attribute
skybolt.css('src/css/critical.css')
// Returns inlined <script> with sb-asset attribute
skybolt.script('src/js/app.js')The client script extracts inlined content, caches it, and sets a cookie.
Server reads the sb_digest cookie (Cuckoo filter), detects cached versions match, and outputs standard <link> and <script> tags. Service Worker intercepts and serves from cache.
- Open DevTools → Network tab
- First load: See the HTML response with inlined assets
- Refresh: Notice zero CSS/JS network requests
- Application tab → Service Workers: See
skybolt-sw.jsactive - Application tab → Cache Storage: See cached assets
| Command | Description |
|---|---|
make install |
Install npm dependencies |
make build |
Build assets with Vite |
make serve |
Start Express server |
make dev |
Start Vite dev server (HMR) |
make clean |
Remove dist and node_modules |
make docker-up |
Start with Docker Compose |
make docker-down |
Stop Docker containers |
- Node.js 18+
- npm