Skip to content

MDD72/offline-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Offline Caching Proxy Server

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.

Installation

npm install

Run

npm start

Browser configuration (3 steps)

1. Install the CA certificate

The 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):

  1. Open Settings → Privacy and Security → Security → Manage certificates
  2. In the "Trusted Root Certification Authorities" tab, click Import
  3. Select the file ca.crt.pem

Firefox:

  1. Open Settings → Privacy & Security → Certificates → View Certificates
  2. In the "Authorities" tab, click Import
  3. Select the file and check "Trust this CA to identify websites"

2. Configure a proxy in your browser

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)

3. Browse normally

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!

How it works

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

API

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

Environment variables

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

Structure

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)

About

A server that will serve you when you are offline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors