sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.53k stars 1.91k forks source link

Vercel ISR pages are slow to load the first time #9673

Open mquandalle opened 1 year ago

mquandalle commented 1 year ago

Describe the bug

When my app is deployed on Vercel I expect ISR pages to be pre-rendered so that they load quickly the first time a user hit them. But it is not the case, and it's not clear how to pre-rendered them at build time.

Reproduction

https://sveltekit-isr-prerender-issue.vercel.app

Source : https://github.com/mquandalle/sveltekit-isr-prerender-issue

Logs

No response

System Info

System:
    OS: Linux 6.2 Pop!_OS 22.04 LTS
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 1.09 GB / 15.38 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 18.6.0 - ~/.nvm/versions/node/v18.6.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.6.0/bin/yarn
    npm: 8.13.2 - ~/.nvm/versions/node/v18.6.0/bin/npm
  Browsers:
    Brave Browser: 101.1.38.111
    Chrome: 112.0.5615.49
    Chromium: 112.0.5615.49
    Firefox: 111.0.1
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.0.0 
    @sveltejs/kit: ^1.5.0 => 1.15.5 
    svelte: ^3.54.0 => 3.58.0 
    vite: ^4.2.0 => 4.2.1

Severity

annoyance

Additional Information

No response

adrienpicard commented 1 year ago

Yes it looks like pages are not statically generated during build and that would be a great addition.

leoj3n commented 6 months ago

Given my original intuition, I kind of expected export const prerender = true; to still have an effect, similar to this use case.

Seeing as how I was applying ISR to a layout, I also thought it would perhaps be possible to skip ISR for a given sub route via the inverse like export const prerender = false;.

However, these no longer seem to have any affect when ISR is enabled for the given route.

EDIT:

It looks like if you do the following in a +page.server.js:

export const config = { isr: false };

That cancels out the ISR configuration set at the layout level. This is useful as I want all but a few specific routes under this layout to be ISR, and adding the ISR settings to a config export for every page would be more tedious than cancelling out the few that should not be ISR. Perhaps adding a note to this effect in PR #12030 would be helpful?