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

nginx-cache-reader

v1.0.0

Published

parses nginx's cache folder and files

Downloads

9

Readme

nginx-cache-reader

Build Status Version Minimum node version License: MIT

parses nginx's cache folder and files

NPM

This is a CLI client for quickly viewing nginx cache folder information. It can read keys from the cache folder and extract the contents of it.

This can also be used as a library. See API

Prerequisites

  • node >=12.x.x
  • suggested that you enable strictatime for accurate atime. Read this askubuntu post for more info

Install

npm install -g nginx-cache-reader

Usage

nginx-cache-reader --help
Usage: nginx-cache-reader [options] [command]

Options:
  -v, --version                                               output the version number
  -q, --suppress-errors                                       Invalid cache files are ignored
  -h, --help                                                  display help for command

Commands:
  readfolder [options] <nginxcachefolder>                     Displays each cache file info
  readfile [options] <nginxcachefile>                         Displays cache file info
  extractfile [options] <nginxcachefile>                      Extracts body content of cache file
  extractfolder [options] <nginxcachefolder> <extractfolder>  Extracts body content of all cache files to a folder
  help [command]

API

const nginxCacheReader = require('nginx-cache-reader');

nginxCacheReader.parseFolder(nginxCacheFolder, throwError = false)

returns Promise<Array<nginxCacheReader.nginxCacheFile>>.

If one of the cache files is invalid, and throwError is false, the array element will hold {error: true, relativePath, absolutePath} instead.

nginxCacheReader.parseFile(nginxCacheFile)

returns Promise<nginxCacheReader.nginxCacheFile>

type nginxCacheReader.nginxCacheFile

{
    key, // nginx key
    statusCode, // http status code. example: 200
    headers,// http headers. example: {'content-type': 'text/html'}
    body, // stream body of cache file. example usage: body.pipe(destination)
    rawHTTPStatus, // raw http status. example: "HTTP/1.0 200 OK"
    rawHeaders, // raw headers. example: "Content-type: text/html\r\nContent-Length: 100"
    relativePath, // relative path of process.cwd(). example: path_to_cachefile
    absolutePath, // absolute path. example: /path/to/cachefile
    size, // size of cache file
    birthtime, // time of birth. taken directly from fs.statSync(cacheFile)
    mtime, // last modified time. same as above
    atime // same as above
}

API examples

Extracting body of cache file

let cacheFile = await nginxCacheReader.parseFile('path_to_cache_file');
cacheFile.body.pipe(fs.createWriteStream('extracted'));

Reading a cache folder

let cacheFolder = await nginxCacheReader.parseFolder('path_to_cache_folder');
for (let eachFile of cacheFolder) {
    if (!eachFile.error) {
      console.log('Key: ' + eachFile.key);
    }
}

Tests

npm test

Contributing

Contributions, issues and feature requests are welcome.

Feel free to check issues page.

Show your support

Consider giving a ⭐️ if this project helped you. Thank you.

License

MIT