Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-disk-cache

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-disk-cache

Middleware for caching responses sent through [Express](http://expressjs.com/) to disk.

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Express disk cache

Middleware for caching responses sent through Express to disk.

Why does this exist?

Because web servers are good at delivering static files. It's also useful if you have NGINX sitting in front of your node.js webserver and want to take some of the load off it.

This also makes cache invalidation quite simple: just delete the file.

Install

Use your package manager of choice, for example:

npm install express-disk-cache
API

Then include the middleware in your Express app:

var cache = require('express-disk-cache');
Example
var app = Express();

// This will cache every response to disk
// assuming it meets the conditions described below
app.use(cache({
  directory: __dirname + '/cache'
}));
How it works

As I understand it, HTTP response in express and node is a writeable stream. It wraps the res.write and res.end functions so it will work no matter how you send the response, using res.send, res.render, res.sendStatus, res.sendFile etc...

Conditions for caching
  • The cache-control header is not set to no-cache
  • There is no query string in the URL
  • There is no session associated with the request
To do

Check that the URL contains valid characters that we can use to create a file on the file system. Re-implement the filter function used by compression.

FAQs

Package last updated on 22 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc