#Will a server component page with revalidation be as fast as a client component with revalidation?

2 messages · Page 1 of 1 (latest)

sturdy walrus
#

Hi, everyone.

I'm experimenting with the app directory, and have a question regarding loading time/speed. I have a gallery page that fetches all artworks, and a dynamic "slug" route that fetches the data for each individual artwork. Both of these are async functions.

app/frontend/gallery/[slug]

My dynamic"slug" page looks like this:

export const revalidate = 30;

async function getArtwork(slug: string) {
  const res = await getArtworkBySlug(slug);
  return res;
}

export default async function ArtPage({
  params: { slug },
}: {
  params: {
    slug: string;
  };
}) {
  const artworkData = getArtwork(slug);
  const navigationData = getNavigationData();
  const [artwork, navigation] = await Promise.all([
    artworkData,
    navigationData,
  ]);

  {/* some logic not needed for this question */}

  return (
    <>
      ...stuff
    </>
  );
}

In the build report, it looks pretty much like the same as when I previously used the old pages folder and revalidation, and that the pages are (SSG). However, when testing the build, it feels like it loads slower than it used to do with the pages + getStaticProps. The images on the dynamic route are approx. 100kb each, so it might be that, idk.

Is this the right/best approach? Or would you guys have done something differently here? I need to fetch data from a CMS, and I want it to be as fast as possible, but at the same time make sure data updates at the CMS gets revalidated within a reasonable amount of time.

grim cryptBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

      🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>

      ✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
      (if you don't see the option, try refreshing Discord with Ctrl + R)