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 SPA to bust cache #295

Closed
jimafisk opened this issue Oct 17, 2023 · 1 comment
Closed

Fingerprint SPA to bust cache #295

jimafisk opened this issue Oct 17, 2023 · 1 comment

Comments

@jimafisk
Copy link
Member

Following up on an earlier comment #191 (comment). We should auto-generate a hash that could be used to store the clientside app. Each time a new build is made the folder name will change and invalidate the previously cached app. This will fix issues where the correct HTML loads initially, but then the app hydrates and it shows the previously cached version (as seen here). In the future it would be great to only bust the cache for the specific files that changes, but for now this might be the quickest / easiest approach.

jimafisk added a commit that referenced this issue Nov 5, 2023
@jimafisk
Copy link
Member Author

jimafisk commented Nov 6, 2023

This is available in v0.6.29.

Important: This API is subject to change (might end up using different variable names).

You can set this in plenti.json like:

{
  "entrypoint_js": ":fingerprint"
}

Note that if you omit the entrypoint_js key, it defaults to spa for backwards compatibility.

Also, we also renamed the former entrypoint key to entrypoint_html to avoid conflicts - currently this isn't being used because using a dynamic svelte component in router.svelte was throwing console errors.

If using :fingerpring, the value is dynamic so you'll want to set it using magic prop env.entrypointJS in your <head> like:

<script type="module" src={`/${env.entrypointJS}/core/main.js`}></script>

Now on every build the JS scripts will get a unique folder name in the format of a random 10 character string (e.g. XwlUjkLudT)

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