Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sparkbox/cachebust

Package Overview
Dependencies
Maintainers
8
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sparkbox/cachebust

A simple cache buster

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by55.56%
Maintainers
8
Weekly downloads
 
Created
Source

cachebust

Straight forward asset fingerprinting "cachebuster" for production applications.

Requires Node 8.5.0 or higher.

Using cachebust

Installing

npm install @sparkbox/cachebust

The recommended way to use cachebust is to either add your input data in package.json or in a .cachebust.config file (see config).

Running

cachebust: will create your fingerprinted assests & update fingerprinted "source file" names inside the target "template file(s)" as specified in the package.json file or the .cachebust.config file.

If you need to restore your template files, you can run: cachebust --restore

Config

Package.json

Create a key in your package.json file at the root level, with source/target keys.

For example:

{
  ...
  "cachebust": {
      "target": [
          "path/to/source/css/style.css",
          "path/to/source/js/script.js"
      ],
      "source": [
          "path/to/target/template.html"
      ]
  }
  ...
}

Config File

Also you may create a config file in the root of the project directory called .cachebust.config

This will be a JSON object like the following:

{
"cachebust": {
    "target": [
        "path/to/source/css/style.css",
        "path/to/source/js/script.js"
    ],
    "source": [
        "path/to/target/template.html"
    ]
  }
}

Direct Input

cachebust allows you to directly specify the source and the target you'll need to pass in a comma seperated list for example:

cachebust -s path/to/source/css/style.css,path/to/source/js/script.js -t path/to/target/template.html

Note Direct input will override the config and package json cacehebust paramaters.

This will fingerprint the following files:

- path/to/source/css/style.css
- path/to/source/js/script.js

This will then update your template "target" file with the updated filenames:

- path/to/target/template.html

To restore these you'll have to again pass the target and source files:

cachebust -r -s path/to/source/css/style.css,path/to/source/js/script.js -t path/to/target/template.html

CLI Options

You can run cachebust --help for more options.

-V, --version         output the version number
-s, --source [files]  source file(s) to be fingerprinted; comma seperated file list
-t, --target [files]  target file(s), template files that need the fingerprinted asset file names; comma seperated file list
-r, --restore         copies the backup file(s) back to the original; backup file(s) are removed.
-h, --help            output usage information

Ensure that the file lists for -s or --source and -t and --target are comma seperated.

-s dir/path/file.ext,dir/otherpath/otherfile.ext etc.

You can pass in one file (no comma, or mutliple files for both source and target).

You may also specify a single file, without a comma.

License

The MIT License (MIT)

FAQs

Package last updated on 28 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc