Hi @grafik,
I investigated the source code you sent me and managed to reproduce the behavior you're experiencing.
Long story short, this is a normal behavior, but I'll explain what's happening and how to reduce its impact on your website.
What's happening
When logged out of Prismic, the website is able to fetch content of the new page really fast because it's already cached on Cloudflare (you can see a header from the response in the network tab saying Cloudflare cache did hit on each of them)
When connected to Prismic, the website fetches content the same way, but because the toolbar is now loaded it also sets a tracker (it's not an analytics tracker, it just allows us to differentiate your very requests from others). This tracker gets attached to each of your requests to Prismic to enable certain features of the toolbar. Because this tracker gets updated on each page navigation it causes the Cloudflare cache to always miss (which is what we need for the toolbar to function), forcing the request to get fresh data from Prismic directly, which is ultimately slower to resolve.
How to minimize this behavior's impact
Options 1: Going static
It looks like your website is set up in a hybrid mode: it renders the first page on the server and then renders subsequent pages on the client upon navigation
You could reduce the impact of this toolbar's behavior to 0 if you can/want your website to be static. On Netlify this involves updating your build command to be nuxt generate
instead of nuxt build
. You can try it locally with yarn generate && npx serve .output/public
, it did work as expected on my end.
Options 2: Parallelizing your requests
I noticed your requests to Prismic are done in "waterfall" (i.e. one at a time), parallelizing your requests could significantly improve your site's speed when navigating it when connected to Prismic (but it would also improve its build time!)
For example on your index page, you can refactor this code:
const { data: page } = await useAsyncData("homeData", async () => {
const navigation = await prismic.client.getSingle("main_menu");
const home = await prismic.client.getSingle("home");
const footer = await prismic.client.getSingle("footer");
return {
navigation,
home,
footer,
};
});
To this:
const { data: page } = await useAsyncData("homeData", async () => {
const [navigation, home, footer] = await Promise.all([
prismic.client.getSingle("main_menu"),
prismic.client.getSingle("home"),
prismic.client.getSingle("footer"),
]);
return {
navigation,
home,
footer,
};
});
Using this pattern on all your async data calls could greatly reduce the time required to fetch the content of each of your pages.
Let me know if that's clear enough! Happy to elaborate more as needed
P.S. Really cool website and nice pictures!