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

gulp-cachebust

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-cachebust

Generates checksums and renames references to files, useful for cachebusting

  • 0.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-21.34%
Maintainers
2
Weekly downloads
 
Created
Source

gulp-cachebust

Generates checksums and renames references to files

Travis build status Dependency status MIT Licence

Useful for cachebusting

This plugin is only compatible with files that contain a stream, it only works in buffer mode.

This is the new repository for gulp-cachebust plugin. The plugin was originaly created by Josiah Truasheim and it has been transfered to this new repository (link to the previous one). Development will continue in this repository.

Install

Install with npm

npm install --save-dev gulp-cachebust

Example

var gulp = require('gulp');
var CacheBuster = require('gulp-cachebust');

var cachebust = new CacheBuster();

gulp.task('build-css', function () {
    return gulp.src('styles/*.css')
        // Awesome css stuff
        .pipe(cachebust.resources())
        .pipe(gulp.dest('dist/css'));
});

gulp.task('build-html', ['build-css'], function () {
    return gulp.src('templates/*')
        // Awesome html stuff
        .pipe(cachebust.references())
        .pipe(gulp.dest('dist'));
});

API

new CacheBuster(options)

options.checksumLength

Optional

Type: Number Default: 8

options.random

Generates the checksum based on a random sha1 hash and not on the file contents.
Useful for changing the file names on each deploy regardless if the content was changed or not.

Optional

Type: Boolean Default: false

options.pathFormatter

Specify a custom formatting function for busted paths. The default will output filenames like /path/to/basename.[hash].ext.

Optional

Type: Function Default: null

An example for outputing a custom hash prefix:

{
    pathFormatter: function(dirname, basename, extname, checksum) {
        return require('path').join(dirname, basename + '._v' + checksum + extname);
    }
}

CacheBuster.resources()

Renames and collects resources according to their MD5 checksum.

CacheBuster.references()

Rewrites references to resources which have been renamed according to their MD5 checksum.

License

MIT © Josiah Truasheim

FAQs

Package last updated on 16 Sep 2019

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