npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

web-cache

v0.1.1

Published

A seamless web cache

Readme

#Web Cache A seamless web cache for web servers.

Version 0.1.1

Build Status

Using Redis as a backend, the cache allows the server to avoid making repeated expensive or long-waiting route handling. This is useful for serving static content or a relatively static data API.

This module acts as middleware for web servers built on Connect, such as Express. Other than configuring it in the web server, it does not require any other custom code. It also has some sensible defaults so you can hit the ground running.

The cache expires items not accessed after a configurable age.

Note that a Redis server needs to be running for the cache to operate.

##Example

var express = require('express'),
    cache   = require('web-cache');

var app = express();

app.configure(function () {
    app.use(cache.middleware({
        path:    '/api',
        exclude: [ /ignore\/.*\/path/ ],
        expire:  86400 // One day
    }));
});

// This path will be cached
app.get('/api/resource/:id', function (req, res, next) {
    // Fancy-pants calculation
    res.end(/* Large JSON object */);
});

app.get('/docs/:id');                 // Will NOT be cached
app.get('/api/list/ignore/:id/path'); // Will NOT be cached

app.listen(3000);

Installation

The module can be downloaded from the NPM Registry using:

npm install web-cache

API

The only API call Web Cache supports (at the moment) is middleware.

###client.middleware(params) Provides Redis-based caching for the web server. params is an associative list with the following supported properties:

  • prefix: string [default: web-cache]

    The prefix to use for caching. Useful for running multiple caches on the same server.

  • expire: integer [default: 86400]

    The age of items (in seconds) at which to expire them from the cache.

  • path: string or RegExp [default: /]

    The path matching routes that should be cached.

  • keyGen: function [optional]

    A custom key generator. Accepts the URL string and expected to return another.

  • exclude: array of string or RegExp [default: null]

    A list of routes which the cache should exclude.

  • host: string [default: 127.0.0.1]

    The Redis host.

  • port: string [default: 6379]

    The Redis port.

  • clean: boolean [default: false]

    Remove all currently-cached items.

##Limitations The following are temporary and are being implemented, or thought about.

  • Will not cache multiple chunks from streaming responses.
  • No limit on size or count of cached items.
  • Not using Cache-Control headers at the moment.

##Changelog ####v0.1.1

  • Supports a custom key generator.
  • Fixes a bug with unordered query parameters.
  • Other fixes and improvements.

####v0.1.0

  • Allows caching of unordered query parameters [#2].
  • Default path now caches everything below root [#1].
  • Improved documentation.
  • Other bug fixes.

####v0.0.3

  • Only caches responses with non-error statuses (200).

##License Copyright (c) 2013 Shiran Pasternak [email protected]

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.