Skip to content
/ uFileCache Public

A minimal static file cache handler for uWebSocket.js

Notifications You must be signed in to change notification settings

erf/uFileCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uFileCache

A minimal static file cache handler for uWebSocket.js

NOTE: Only for small files.

Installation

Add the following to your package.json file:

{
  "dependencies": {
	"uFileCache": "github:erf/uFileCache"
  }
}

Then run npm install.

Usage

// import the modules 
import uWS from 'uWebSockets.js'
import FileCache from 'uFileCache'

const fileCache = new FileCache()

// load files in folder to memory
fileCache.init('public')

// create a new app
const app = uWS.App()

// index.html
app.get('/', (res, req) => fileCache.send('./public/index.html', res))

// static files
app.get('/*', (res, req) => fileCache.send(`./public${req.getUrl()}`, res))

Test

node --test --no-warnings=ExperimentalWarning

About

A minimal static file cache handler for uWebSocket.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published