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

cachepuncher

v0.1.3

Published

Punch browser caching right in the cache

Downloads

13

Readme

cachepuncher

Punch browser caching straight in the cache!

Cockpuncher (the Onion Movie)

Don't you just hate browsers that cache overly aggressively? Yes, I'm looking at you Chrome and Mobile Safari, you rule breaking maniacs. It's time for the cache puncher!

This tiny piece of software will generate a unique time-based code that you can inject into your URLs whenever you need to do some ajax or image loading. It guarantees no two codes are the same, even if generated within the same millisecond. It comes with a few options to further shrink down the code if you care a lot about saving a few extra precious bytes.

Installation

Install with component(1):

$ component install wizcorp/cachepuncher

The output format

Cache puncher always returns a code that is URL friendly, so no further URL escaping is needed (though it won't break if you do encode it). The output format is a numerical (base 2-36, you choose) timestamp, followed by an iteration number to avoid collisions within a single timestamp. You may change the output rules for each punch, and cache puncher will still guarantee uniqueness for each generated code.

API

A cache puncher instance has only one function that will keep generating unique codes: punch.

Simple example

Example:

var punch = require('cachepuncher').punch;

var image = new Image();
image.src = 'http://example.com/punch.jpg?rand=' + punch();

Arguments

The punch function takes arguments:

var code = punch({
	msec: true,
	base: 16,
	epoch: new Date(2013, 0, 1, 0, 0, 0)
});

| option | type | default | meaning | |--------|---------|------------|---------| | msec | boolean | false | Output milliseconds. Useful (but not required) if you need many codes per second. | | base | number | 10 | Output the code in base-N, eg 16 for hex. Must be between 2 and 36. | | epoch | Date | unix epoch | Set a custom epoch, to lower the output number. |

Cache puncher instances

You can use the default cache puncher as shown in the example above, or you can create your own with default settings for the punch function.

Example:

var puncher = require('cachepuncher');
var punch = puncher.create({ base: 36 });  // output in base 36 by default

var image = new Image();
image.src = 'http://example.com/punch.jpg?rand=' + punch();

About the name

It's a wink to the fake movie Cock Puncher starring the awesome Steven Seagal, featured in the hilarious The Onion Movie. I wish they made Cock Puncher an actual movie. Please don't sue me for using the image, and don't punch my cock either please.

License

MIT