Skip to content

Use [contenthash] over [hash] and [chunkhash] for better long term caching #2096

Closed
@alexander-akait

Description

@alexander-akait

For long term caching better use [contenthash] over [chunkhash].

From slack

sokra [2:59 PM]
A chunk contains modules i. e. a.js, b.css, and c.wasm. This results in 3 assets being generated JS, CSS and WASM. `[chunkhash]` is the hash of the complete chunk, which is JS + CSS + WASM. `[contenthash]` is the hash of the content of the file, which is different for each asset.

evilebottnawi [3:10 PM]
I.e. better use `[contenthash]` for chunks?

sokra [5:26 PM]
@evilebottnawi better use `contenthash`.

sokra [5:30 PM]
we probably should rename that in webpack 5 to `[hash]`.

evilebottnawi [5:34 PM]
Only one question why we need `chunkhash` after implement `contenthash` :smile: ?

sokra [5:39 PM]
not sure if there is a use case where chunkhash is better, but at least for backward-compat

Ref on issue in webpack webpack/webpack#7138.
Example of problem webpack-contrib/mini-css-extract-plugin#117.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions