Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds contents hash to support browsers cache invalidation #936

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

melegiul
Copy link
Contributor

Short description

Invalidates the browser cache by adding content hashes to output file names of webpack

Proposed changes

  • Sets webpack output file name to [name].[contenthash].js
  • To keep only the latest file hash, the webpack output.clean option is used
  • To use output.clean it is necessary to switch from webpack serve to webpack watch (see 861)
  • To include the renamed webpack output into djangos templates django-webpack-loader is used

Alternatives

Instead of django-webpack-loader we could also use HTMLwebpackPlugin to include the webpack output files. but this approach seemed to have problems with djangos templates format (maybe I just used the wrong template loader, I'm not sure)

Resolved issues

Fixes: #822

.circleci/config.yml Outdated Show resolved Hide resolved
Pipfile.lock Outdated Show resolved Hide resolved
@melegiul melegiul marked this pull request as ready for review September 22, 2021 09:01
Pipfile Outdated Show resolved Hide resolved
Copy link
Member

@svenseeberg svenseeberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 👍

Uses webpacks output clean option to erase the old webpack outpus files
To use output clean we have to switch from webpack serve to webpack watch for the moment
@melegiul melegiul changed the title Adds contents hash to improve caching webpack output Adds contents hash to support browsers cache invalidation Sep 27, 2021
@melegiul melegiul merged commit d15cd49 into develop Sep 27, 2021
@melegiul melegiul deleted the feature/webpack-cache branch September 27, 2021 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalidate cache for static files after they changed
3 participants