Skip to content

fix(cache): replace hardcoded asset preload URLs with source URLs#2750

Merged
contolini merged 3 commits intomasterfrom
min-cache
May 5, 2026
Merged

fix(cache): replace hardcoded asset preload URLs with source URLs#2750
contolini merged 3 commits intomasterfrom
min-cache

Conversation

@contolini
Copy link
Copy Markdown
Member

Vite replaces the URLs at build time with hashed minified versions.

See https://vite.dev/guide/assets.html
See https://vite.dev/guide/#index-html-and-project-root

Changes

  • Replace hardcoded USWDS asset URLs with their source URLs.

Testing

  1. Run yarn build and yarn start locally and check out the generated index.html file in the /dist dir.

Copy link
Copy Markdown
Contributor

@billhimmelsbach billhimmelsbach left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Also... I put it up on staging and found some weird behaviors maaaaybe?

Looks like uswds.min.js gets downloaded twice maybe?

First Load

Image

Second Load

Screenshot 2026-04-30 at 10 26 48 AM

The uswds.min.js that is served from the disk cache is yours, but then it's still getting imported again over here in Header.jsx which is the one served from the memory cache.

Also, I'm not sure if the uswds-init.min.js is actually be preloaded? Looks like it's being served from the memory cache from the Header.jsx import instead of from the preload. Here's what the preload looks like, looks like in the index:

Image

Mind taking a quick peek? We can always just remove the preloads and see if it hits our lighthouse scores still, but maybe see if it's a quick fix?

@contolini
Copy link
Copy Markdown
Member Author

Lol okay how do you feel about just deleting the two preloads? It feels so dirty hardcoding the hashed filename into the HTML file. On staging, their deletion bumps the homepage from a 95 lighthouse score to a 98 so hey that's a success?

before after
image image

I tried modulepreload over in 02f91f0 but it had no effect due to the structure of our app.

@billhimmelsbach
Copy link
Copy Markdown
Contributor

Yeah, let's remove them for now! 🚀

@contolini
Copy link
Copy Markdown
Member Author

Yeah, let's remove them for now! 🚀

K they dead 84f9b59

Copy link
Copy Markdown
Contributor

@billhimmelsbach billhimmelsbach 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! Good riddance!

@contolini contolini merged commit ab61360 into master May 5, 2026
1 check passed
@contolini contolini deleted the min-cache branch May 5, 2026 19:56
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.

2 participants