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

Hash API routes for static builds #2330

Open
WaltzingPenguin opened this issue Aug 30, 2021 · 0 comments
Open

Hash API routes for static builds #2330

WaltzingPenguin opened this issue Aug 30, 2021 · 0 comments
Labels
feature / enhancement New feature or request
Milestone

Comments

@WaltzingPenguin
Copy link

WaltzingPenguin commented Aug 30, 2021

Describe the problem

SvelteKit always fetches a new copy of a route's data when navigating to a new page or using sveltekit:prefetch. If the website was built using the static adaptor, we know the data is static and there is no need to refetch and check for updates.

If you visit https://svelte-demo.jamcart.io/, use dev tools to throttle the connection, and use the browser's back/forward buttons to navigate, then that delay becomes noticeable. This is not an issue for Next.js (https://react-demo.jamcart.io/), Nuxt.js (https://vue-demo.jamcart.io/), or even just static html (https://astro-demo.jamcart.io/).

Describe the proposed solution

Adopt Next/Nuxt's approach. Instead of writing files out to /api/my-endpoint.json, it could be instead rewritten to /_app/{ BUILD HASH OR TIMESTAMP }/api/my-endpoint.json. Then, developers can simply apply Cache-Control: public, immutable to everything inside of /_app.

Alternatives considered

For a static built, SvelteKit could just keep previous requests in memory and not force a refetch.

Importance

nice to have

Additional Information

No response

@Rich-Harris Rich-Harris added this to the post-1.0 milestone Apr 22, 2022
@benmccann benmccann added the feature / enhancement New feature or request label Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants