#vercel isr revalidation

8 messages · Page 1 of 1 (latest)

compact trench
#

import { defineConfig } from 'astro/config';
import tailwind from "<@&1055234544183287879>/tailwind";
import db from "<@&1055234544183287879>/db";
import react from "<@&1055234544183287879>/react";
import clerk from "astro-clerk-auth";

import vercel from "<@&1055234544183287879>/vercel/serverless";

// https://astro.build/config
export default defineConfig({
integrations: [tailwind(), db(), react(), clerk()],
output: "server",
adapter: vercel({
isr: {
expiration: 60 * 60 * 8,
exclude: ["/dashboard/(.*)", "/dashboard/", "/dashboard", "/sign-in", "/sign-up"]
}
})
});

I'm expecting with this that the home page and other than excluded pages would be revalidated every 8 hours? But that doesnt seem to be the case, how can i achive that?

viral plumeBOT
#

Hi @compact trench. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The isr configuration in your astro.config.mjs file is indeed set to revalidate every 8 hours (60 seconds * 60 minutes * 8 hours). However, please note that the isr configuration allows your project to be deployed as an Incremental Static Regeneration (ISR) function, which caches your on-demand rendered pages in the same way as prerendered pages after the first request.

If you're not seeing the expected behavior, it could be due to a few reasons:

  1. The pages might not have been requested yet. ISR works by caching the pages after the first request. If a page hasn't been requested, it won't be regenerated.

  2. There might be an issue with the way the exclude array is being processed. According to a Github issue (https://github.com/withastro/astro/issues/10492), all the routes that are passed into the isr.exclude array are matched exactly as is. If you're trying to exclude dynamic routes, this might not work as expected.

  3. There could be an issue with the deployment or the Vercel adapter. If there's an error during the build or deployment process, ISR might not work as expected.

To troubleshoot, you could try the following:

  • Check the Vercel deployment logs to see if there are any errors.
  • Try removing the exclude array or using exact routes to see if that changes the behavior.
  • Make sure the pages you're testing have been requested at least once.

If you're still having issues, you might want to open an issue on the Astro Github page or reach out to the Astro or Vercel community for help.

#

@compact trench kapa.ai is still learning and improving, please let us know how it did by reacting below

compact trench
#

@viral plume OK so the code is right, if a new visitor comes after 8 hours this should trigger a revalidation correct?

viral plumeBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, that's correct. With the isr configuration you've set, if a new visitor comes to the page after 8 hours from the last generation, it should trigger a revalidation. This means that Vercel will serve the stale (cached) page to the visitor, and in the background, it will regenerate the page. The next visitor will then get the newly generated page.

This is part of the Incremental Static Regeneration (ISR) strategy, which allows you to have static pages that are updated incrementally after they are first generated, providing a balance between performance (by serving static pages) and freshness of data.

Remember, this revalidation process will happen only if the page has been requested at least once before. If a page hasn't been requested yet, it won't be in the cache and therefore won't be regenerated.

Source: Astro Documentation - Vercel ISR Configuration (https://docs.astro.build/en/guides/integrations-guide/vercel#isr)

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: