netlify-plugin-hashfiles

4.0.2 • Public • Published

Netlify Hashfiles Build Plugin

NPM version Build Status Coverage Status Dependency Status Greenkeeper badge

Hashfiles sets you up with an optimal caching strategy for static sites, where static assets across pages are cached for as long as possible in the visitors browser and never have to be re-requested.

Hashfiles will move your static into a single static file directory which it sets up with immutable cache headers. All static files will be renamed to contain a hash of their content, making them content-addressable and thus well suited for immutable caching.

Relevant files that need to retain their names are not moved:

  • Entry points
  • HTML pages with incoming links
  • /favicon.ico
  • /*.txt
  • Cache manifests
  • Serviceworkers
  • News feeds (RSS, Atom)

Installation

To install, add the following lines to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-hashfiles"

The [[plugins]] line is required for each plugin, even if you have other plugins in your netlify.toml file already.

IMPORTANT NOTE: Hashing files has to be the last thing you do before deploying. Make sure you add hashfiles at the bottom of your plugin configuration.

Configuration

Hashfiles works out of the box, but can be improved upon with some improved knowledge about your site.

These are the configuration options with their default values:

[[plugins]]
package = "netlify-plugin-hashfiles"
 
  [plugins.inputs]
  # An array of glob patterns for pages on your site. Recursive traversal will start from these
  entryPoints = [
    "*.html"
  ]
 
  # Directory where content-addressable files are moved and immutable cache-headers are set
  staticDir = "/static/"

License

BSD 3-Clause License

Package Sidebar

Install

npm i netlify-plugin-hashfiles

Weekly Downloads

26

Version

4.0.2

License

BSD-3-Clause

Unpacked Size

16.7 kB

Total Files

6

Last publish

Collaborators

  • munter