
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
request-http-cache
Advanced tools
A request "middleware" for caching HTTP responses in-memory or in Redis. Built for Gitter's communications with GitHub as part of Tentacles, although it's intended as a general purpose HTTP caching module that should work with any request HTTP client.
npm install request-http-cache
This module is intended for use with request-extensible.
It is designed to honor the HTTP caching semantics used by the GitHub API and use Conditional Requests, using ETags, for stale responses while correctly handling Vary headers.
var requestExt = require('request-extensible');
var RequestHttpCache = require('request-http-cache');
var httpRequestCache = new RequestHttpCache({
max: 1024*1024 // Maximum cache size (1mb) defaults to 512Kb
});
var request = requestExt({
extensions: [
httpRequestCache.extension
]
});
// Now use request as you would request/request
request({ url: 'https://api.github.com/users/suprememoocow' }, function(err, response, body) {
});
When using with a Redis backend, it's highly recommended to use maxmemory and
maxmemory-policy configurations to ensure that the Redis memory usage doesn't
grow out of control.
var requestExt = require('request-extensible');
var RequestHttpCache = require('request-http-cache');
var httpRequestCache = new RequestHttpCache({
backend: 'redis',
redis: {
host: "localhost",
port: 6379
},
redisClient: redisClient, // Or you can pass in your Redis client
ttl: 86400 // Maximum cached response time
});
var request = requestExt({
extensions: [
httpRequestCache.extension
]
});
// Now use request as you would request/request
request({ url: 'https://api.github.com/users/suprememoocow' }, function(err, response, body) {
});
When a new outgoing request is made, the Vary headers for the URL endpoint are looked up in the cache.
If-None-Match headerSnappy compression and protobuf serialization of cached data is supported. However in tests, it is generally slower than JSON and no compression, so it's disabled by default.
To enable it, use one of both of the serializer and/or compressor options:
var httpRequestCache = new RequestHttpCache({
backend: 'redis',
serializer: require('request-http-cache-protobuf-serializer'),
compressor: require('request-http-cache-snappy-compressor')
});
You will need to require the respective modules as these are no longer shipped
with request-http-cache.
If-Modified-Since conditional responses (currently only uses ETags)Cache-Control headersExpires headers (currently only uses Cache-Control's max-age)Pull requests welcome.
Built by @suprememoocow and the team at Gitter.
License
The MIT License (MIT)
Copyright (c) 2015, Troupe Technology Limited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FAQs
HTTP Caching extension for request-extensible
The npm package request-http-cache receives a total of 84 weekly downloads. As such, request-http-cache popularity was classified as not popular.
We found that request-http-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.