New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

express-rc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-rc

Basic HTTP cache middleware for Express.js

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Express.js caching middleware

Install

yarn install express-rc

Usage


'use strict';

const express = require('express');
const redis = require('redis');
const cache = require('cache');

const app = express();

app.use(cache({
	ttl: 60 // How long (in seconds) to hold onto cached responses
	enabled: true, // Enable caching (setting exists to easily disable in specific environments)
	includeBody: true, // Include the body in hashing the request
	disabled: [ // Specify some routes that shouldn't be cached
		'/ping',
		'/auth'
	],
	headers: [ // Any unique headers you want to include when hashing the request
		'X-Access-Token'
	],
	client: redis.createClient() // A node redis client
}));

app.use('/', (req, res) => {
	res.ttl(5) // Optionally override the global ttl in middleware
	return next();
});

What Express response methods are cached?

  • .set()
  • .send()
  • .json()
  • .status()

Keywords

express

FAQs

Package last updated on 01 Feb 2017

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