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

mimosa-asset-cache-bust

v2.0.0

Published

mimosa module to rename assets files appending a file digest providing a unique name, so breaking the browser cache, when they change

Downloads

7

Readme

Mimosa Asset Cache Bust

WARNING I've stopped to maintain this modules, so I'm happy to move the ownership of this repository if somebody is interested in maintaining it, refer to this issue

Overview

Mimosa module for assets cache busting.

The current release is for Mimosa v3.0, if you would to use it with a previous mimosa version then use for:

  • miomsa 2.0 release use 1.0.0.
  • mimosa previous 2.0 release use 0.0.3.

For more information regarding Mimosa, see http://mimosa.io

Usage

Add asset-cache-bust to your list of modules. That's all! Mimosa will install the module for you when you start up.

Functionality

The module renames the assets left in the compiled directory (compildedDir property from watch Mimosa configuration section) which match the paths and/or file name patterns from the files option configuration of this module.

The module only performs when optimization flag (-o or --optimize) but it can be run as a mimosa command mimosa bust-assets.

Bear in mind the module doesn't provide any mechanism to change the views and/or templates where they are referenced, so it is your task to find out how to update the references; e.g. in server template engine you may have a function that resolve the name depending of your environment and returning each appropriated asset's name base by an id.

Configuration

Default

The default configuration added to your mimosa configuration file when the module is installed is:

assetCacheBust:
  hash: 'md5'
  splitter: '-'
  files: []

Properties

The default configuration has all the configuration parameters that this module has and they are commented. Bear in mind that by default the files configuration property is an empty array, so it means that any asset will busted.

  • hash: It defines the digest algorithm supported by node crypto API to use to work out a uniquely identifier for each asset regarding its content.
  • splitter: The character(s) to use to separate the worked hash digest of the asset from the original name, to be used to rename the asset; if the file has an extension the hash digest will be added between the name and the extension.
  • files: A string array of paths with or without a file name pattern to match files in the compilation directory (mimosa compileDir property of watch section) which have to be busted. Path are relative to the compilation directory; when all the assets (files) should be busted from a directory, a path with file name pattern must be defined and to allow to this module to distinguish between them, it must end with '/', bearing in mind that only files in that path are matched, so the descendant directories are skipped, it means that the modules doesn't recurse into subdirectories. When only some files or just one should be busted, then a file pattern must be used after the path directory; a file pattern is a string which will be used to create a regular expression (just calling new RegExp constructor), so make sure that when you write them, you scape the regular expression special characters to fit what file names you would like to match.

Example

Here, you can see an example to set up module; the files property matches all the javascript files (files with 'js' extension) are in 'scripts' directory and all the files are in 'stylesheets' directory; remember that those directories are related to the directory compilation 'compileDir'.

assetCacheBust:
  hash: 'sha1'
  splitter: '='
  files: ['script/.*\\.js', 'stylesheets/']

The internals

The module renames the matched files appending to the original name (between the name and the extension), separated by the splitter configuration, a hash digest worked out from the content of the file. The digest algorithm to use is defined by the configuration's hash property, which must match to a supported hash digest algorithm by node crypto API.

License

The MIT License, for more information read the LICENSE file