A proxy server that intercepts all HTTP/HTTPS traffic from the browser, caches the responses, and serves them offline. Files remain with regular URLs – no need to change anything in the code.
npm installnpm startThe server issues a dynamic SSL certificate per domain (MITM) to read and store HTTPS traffic. You need to install the root certificate (CA) in your browser/system:
- Browse to:
http://localhost:8080/__proxy__/ca.crt - Or find the file in:
certs/ca.crt.pem
Chrome/Edge (Windows):
- Open Settings → Privacy and Security → Security → Manage certificates
- In the "Trusted Root Certification Authorities" tab, click Import
- Select the file
ca.crt.pem
Firefox:
- Open Settings → Privacy & Security → Certificates → View Certificates
- In the "Authorities" tab, click Import
- Select the file and check "Trust this CA to identify websites"
Configure an HTTP and HTTPS (SSL) proxy to:
localhost:8080
Chrome/Edge (Windows):
- Settings → System → Open proxy settings → Manual proxy →
localhost:8080 - or run chrome
chrome --proxy-server="http://127.0.0.1:8080" - Or use In an extension like SwitchyOmega
Firefox:
- Settings → Network Settings → Manual proxy:
localhost:8080(both HTTP and HTTPS)
Now browse your website as usual. All external resources (JS, CSS, images) are downloaded and saved automatically.
Disconnect the internet – and everything cached will continue to work!
Browser ──proxy──> Offline Server ──fetch──> Internet
│
[Cache on disk]
│
Browser <───────── Serves from cache (online or offline)
- HTTP: The server intercepts requests and saves the responses
- HTTPS: The server performs MITM (with a dynamic certificate) to read and save content
- Offline: If the request fails, the server returns from the cache
| Endpoint | Description |
|---|---|
GET /__proxy__/ca.crt |
Download the root certificate (CA) |
GET /__proxy__/status |
Server status and number of files in the cache |
POST /__proxy__/clear-cache |
Clear the cache |
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
Server/Proxy Port |
STATIC_DIR |
./public |
Static Files Folder (Direct Browsing) |
CACHE_DIR |
./cache |
Cache Folder |
CERTS_DIR |
./certs |
SSL Certificates Folder |
offline-server/
├── server.js # Server + Proxy + MITM
├── package.json
├── public/ # Static files (direct access without proxy)
│ └── index.html
├── cache/ # Automatic cache by protocol/host/path
│ ├── https/
│ │ ├── cdn.jsdelivr.net/...
│ │ └── unpkg.com/...
│ └── http/...
└── certs/ # SSL certificates
├── ca.key.pem # CA private key
└── ca.crt.pem # CA certificate (for installation in browser)