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

Fingerprint every file in SPA #320

Open
jimafisk opened this issue May 2, 2024 · 4 comments
Open

Fingerprint every file in SPA #320

jimafisk opened this issue May 2, 2024 · 4 comments

Comments

@jimafisk
Copy link
Member

jimafisk commented May 2, 2024

We recently updated our cache busting strategy to use query params: #315

My hope was that breaking the entrypoint would have a cascade effort to breaking other cached files referenced downstream. I thought this was working based on initial tests, but that does not seem to be the case now that I've used it more extensively.

It puts us in a hard place, breaking the cache using a folder runs the risk of inactive Chrome tabs not correctly fetching the assets when reactivating, and only breaking the entrypoint runs the risk of serving up stale content already cached. I think we're going to have to ultimately fingerprint (with query string) every file in the SPA. We should be able to do this using gopack, since we're already rewriting every import to resolve to a valid ESM path during the build.

@jimafisk
Copy link
Member Author

jimafisk commented May 2, 2024

In my initial testing I was running into parent_component is null errors: sveltejs/svelte#6584

After doing several cache clears ctrl-f5 and using incognito/private browsing windows, it appears to work as expected and I can't recreate the error. If folks do run into this however, please let me know!

@jimafisk
Copy link
Member Author

jimafisk commented May 2, 2024

I attempted to load the fingerprint only when replacing the import path (1005ca6). This resulted in a different fingerprint for each import. This was not my intention, but I didn't think this would be a problem, but it kept throwing the parent_component is null (firefox) / Cannot read property '$$' of null (chrome/brave) errors. I'm still not entirely sure why that is, maybe has something to do with imports from different files referencing the same component (still not sure why that would matter), but reverting for now seems to fix the issue. I'm somewhat worried because I saw this behavior even when passing the same fingerprint throughout gopack, although I can't recreate that now.

jimafisk added a commit that referenced this issue May 2, 2024
jimafisk added a commit that referenced this issue May 2, 2024
@jimafisk
Copy link
Member Author

jimafisk commented May 2, 2024

I can't seem to avoid the parent_component is null (firefox) / Cannot read property '$$' of null (chrome/brave) errors from periodically happening when trying to individual fingerprint each file. I'm going to revert these changes for now until we can figure out a better solution.

@jimafisk
Copy link
Member Author

I found a good way to replicate the issue with the hashed folder in case folks want to test:

  1. Open several tabs with a locally running plenti site
  2. Make a change in your editor that kicks off a rebuild
  3. Close the browser so all tabs are closed
  4. Reopen the browser and restore the tabs
  5. Visit the already open site and it will load the old hash (which no longer exists)

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

No branches or pull requests

1 participant