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

Add css & js webpack cache bust #4100

Merged
merged 1 commit into from
Jul 4, 2024
Merged

Conversation

cstns
Copy link
Contributor

@cstns cstns commented Jul 4, 2024

Description

Add webpack cache bust capability for front end assets (css/js)

docs: https://webpack.js.org/guides/caching/

Related Issue(s)

closes #4098

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Includes a DB migration? -> add the area:migration label

@cstns cstns self-assigned this Jul 4, 2024
@cstns
Copy link
Contributor Author

cstns commented Jul 4, 2024

image

All js/css assets should now be prepended with a hashed value based on their contents. When this hashed value changes it will force the browser to reload said assets and bust it's cache

@cstns
Copy link
Contributor Author

cstns commented Jul 4, 2024

webpack build output should reflect same hashed values as loaded in the browser:
image

@cstns
Copy link
Contributor Author

cstns commented Jul 4, 2024

staging built assets with new hashes:

#15 79.70 warn - You have enabled the JIT engine which is currently in preview.
#15 79.70 warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
#15 109.8 assets by info 5.45 MiB [immutable]
#15 109.8   assets by path ./assets/ 315 KiB 12 assets
#15 109.8   assets by path *.js 5.04 MiB 5 assets
#15 109.8   assets by path *.css 102 KiB
#15 109.8     asset main.95260d59a4e3571960d2.css 50.8 KiB [emitted] [immutable] (name: main)
#15 109.8     asset setup.95260d59a4e3571960d2.css 50.8 KiB [emitted] [immutable] (name: setup)
#15 109.8 assets by path ../ 26.7 KiB
#15 109.8   assets by path ../*.png 9.75 KiB
#15 109.8     asset ../ff-logo--wordmark-caps--dark.png 8.91 KiB [emitted] [from: frontend/public/ff-logo--wordmark-caps--dark.png] [copied]
#15 109.8     asset ../favicon-32x32.png 524 bytes [emitted] [from: frontend/public/favicon-32x32.png] [copied]
#15 109.8     asset ../favicon-16x16.png 341 bytes [emitted] [from: frontend/public/favicon-16x16.png] [copied]
#15 109.8   asset ../favicon.ico 15 KiB [emitted] [from: frontend/public/favicon.ico] [copied]
#15 109.8   asset ../../dist-setup/setup.html 983 bytes [emitted]
#15 109.8   asset ../index.html 954 bytes [emitted]
#15 109.8 asset favicon.ico 15 KiB [emitted]
#15 109.8 Entrypoint main [big] 2.46 MiB (315 KiB) = runtime.0fe3871cfbbab18136eb.js 3.45 KiB vendors.6a0287064d4a7dcf0589.js 1.03 MiB main.95260d59a4e3571960d2.css 50.8 KiB main.5cfa94b6855d4f4bd477.js 1.38 MiB 12 auxiliary assets
#15 109.8 Entrypoint setup [big] 2.43 MiB (315 KiB) = runtime.0fe3871cfbbab18136eb.js 3.45 KiB vendors.6a0287064d4a7dcf0589.js 1.03 MiB setup.95260d59a4e3571960d2.css 50.8 KiB setup.c07c15d94e17574ce4f4.js 1.35 MiB 12 auxiliary assets
#15 109.8 orphan modules 4.02 MiB (javascript) 8.24 KiB (runtime) [orphan] 2356 modules
#15 109.8 runtime modules 8.86 KiB 17 modules
#15 109.8 built modules 6.49 MiB (javascript) 315 KiB (asset) 50.8 KiB (css/mini-extract) [built] 743 modules
#15 109.8 
#15 109.8 WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
#15 109.8 This can impact web performance.
#15 109.8 Assets: 
#15 109.8   main.5cfa94b6855d4f4bd477.js (1.38 MiB)
#15 109.8   setup.c07c15d94e17574ce4f4.js (1.35 MiB)
#15 109.8   async-vendors.cb8fa64356060c9dc31f.js (1.28 MiB)
#15 109.8   vendors.6a0287064d4a7dcf0589.js (1.03 MiB)
#15 109.8 
#15 109.8 WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
#15 109.8 Entrypoints:
#15 109.8   main (2.46 MiB)
#15 109.8       runtime.0fe3871cfbbab18136eb.js
#15 109.8       vendors.6a0287064d4a7dcf0589.js
#15 109.8       main.95260d59a4e3571960d2.css
#15 109.8       main.5cfa94b6855d4f4bd477.js
#15 109.8   setup (2.43 MiB)
#15 109.8       runtime.0fe3871cfbbab18136eb.js
#15 109.8       vendors.6a0287064d4a7dcf0589.js
#15 109.8       setup.95260d59a4e3571960d2.css
#15 109.8       setup.c07c15d94e17574ce4f4.js
#15 109.8 

@knolleary knolleary self-requested a review July 4, 2024 08:46
@knolleary knolleary merged commit c462ac1 into main Jul 4, 2024
12 checks passed
@knolleary knolleary deleted the 4098_add-webpack-cache-busting branch July 4, 2024 08:49
@knolleary
Copy link
Member

Tested locally - looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FE cache busting
2 participants