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 🙏

© 2024 – Pkg Stats / Ryan Hefner

upcache

v2.8.2

Published

nginx proxy cache key protocols implementations

Downloads

107

Readme

upcache

Caching proxy having cache keys configured by the upstream application, by setting http response headers.

Upcache has several ways of changing the cache keys:

  • tag, version resources by zones
  • lock, vary on client json web token grants
  • vary, vary by grouping selected request headers
  • map, maps a request uri to another request uri

Breaking change: server.d/upcache.conf is now server.d/upcache-memcached.conf

Requirements

In debian/12 these packages are easy to install:

  • nginx

  • libnginx-mod-http-srcache-filter

  • libnginx-mod-http-set-misc

  • libnginx-mod-http-memc (if using memcached, or for running the test suite

  • memcached or redis

  • lua-resty-core

  • lua-resty-lrucache

  • a Node.js express app

Install

The Node.js app need the module

npm install upcache

The nginx configuration need the module

luarocks install upcache

nginx is easily configured with the set of files described in (depending on where npm installs the module) ./node_modules/upcache/nginx/README.md.

Usage

Once installed, load appropriate helpers with

const app = express();
const { tag, lock } = require('upcache');
const mlock = lock(config);

app.get('/route', tag('ugc', 'global'), mlock.restrict('logged'), ...);
app.post('/route', tag(), mlock.restrict('logged'), ...);

See README-tag.md and README-lock.md for documentation, and test/ for more examples.

Mind that srcache module honours cache control headers - if the application sends responses with Cache-Control: max-age=0, the resource is not cached, and tag().for() is a facility for doing cache control.

To cache something, resources must be tagged, so lock/vary won't work without tag.

Detection by upstream

Upcache adds a X-Upcache: <version> header to requests, so upstream application can detect it is enabled, and which features are available.

Testing

A pre-configured nginx environment is available for testing a Node.js application that listens on port 3000, with nginx on port 3001 and memcached on port 3002, simply by launching (depending on ./node_modules/.bin being on PATH or not)

npm run upcache

which also has an option for filtering output -g <regexp pattern>.

mocha relies on it for integration tests. No root permissions are needed.

License

See LICENSE file.