New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cache-busting-assets

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-busting-assets

A function that takes an array of files, copies them and appends a unique hash based on the file contents to the file name and returns an object where the original path is the property name and the value is the new file path.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-52.94%
Maintainers
1
Weekly downloads
 
Created
Source

Cache busting assets

A function that takes an array of files, copies them and appends a unique hash based on the file contents to the file name and returns an object where the original path is the property name and the value is the new file path.

Getting Started

npm i --save-dev cache-busting-assets
const cacheBust = require('cache-busting-assets');
const cacheFiles = cacheBust(['/static/assets/js/bundle.js', '/static/assets/js/main.js']);

In this case cacheFiles can be used however you wish, it could be used as a function within server side templating to replace the path

// app.js
  res.nunjucksEnvironment.addFilter('cacheBust', (arg) => {
    return cacheFiles[arg] || arg;
  });

// scripts.html
  <script src={{"/static/assets/js/main.js" | cacheBust}}></script>

or could be used in a build task to move do a string replace on a script tag

.replace('{{"/static/assets/js/main.js"}}', cacheFiles["/static/assets/js/main.js"]);

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

FAQs

Package last updated on 11 Nov 2021

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