Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including x-ray-http-cache with all npm packages installed. Try it out:

var xRayHttpCache = require("x-ray-http-cache")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

x-ray-http-cache v2.0.0

http-cache driver for x-ray


TravisCI Build Status NPM version Dependency Status Development Dependency Status

http-cache driver for x-ray.

Uses superagent-cache for caching.

See it's documentation for supported caching drivers.


npm install x-ray-http-cache --save


var httpCache = require('x-ray-http-cache');

// using redis for caching
var redisModule = require('cache-service-redis');

var redisCache = new redisModule({
  redisUrl: 'http://localhost:6379'

var Xray = require('x-ray');

var x = Xray()
    driver: redisCache,

    cacheWhenEmpty: false,
    expiration: 86400, // 24 hours

    // Optional: provide own superagent instance
    // superagent: require('superagent')

x('', 'title')(function(err, str) {
  console.log('Google', str);

  // close connection to redis when finished


It's currently not possible to determine whether or not to throttle based on cache.

However if you are sure the cache is already populated you can reset throttling using:

x.throttle(Infinity, 0);



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free