Skip to content

Bug/cache fingerprint assets#310

Merged
Mortaro merged 3 commits intonullstack:unstable-nextfrom
LoTerence:bug/cache-fingerprint-assets
Jan 26, 2023
Merged

Bug/cache fingerprint assets#310
Mortaro merged 3 commits intonullstack:unstable-nextfrom
LoTerence:bug/cache-fingerprint-assets

Conversation

@LoTerence
Copy link
Contributor

@LoTerence LoTerence commented Jan 25, 2023

  • Before it was using url.pathname.indexOf(self.context.environment.key) > -1 to find fingerprinted assets, but it wasn't finding them
  • Instead, it was going to the next if statement, so it was using the staleWhileRevalidate strategy for requests to /client.js?fingerprint=0270f3e40e56449d6de75b1a73e4c1d0843e6ef0 for example
  • It didn't work because everything after the ?= is not part of the pathname. I logged the pathname and it only returned /client.js
  • So I changed it to url.searchParams?.get('fingerprint') === self.context.environment.key to get the fingerprint param. This properly activates the cacheFirst strategy

Nullstack docs for fingerprinted assets strategy:
https://nullstack.app/service-worker#server-side-render-strategy

Url.pathname docs:
https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname#examples

@Mortaro Mortaro merged commit f7263bc into nullstack:unstable-next Jan 26, 2023
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