Report this

What is the reason for this report?

NextJS With ISR

Posted on January 8, 2022

Hello,

My plan was to setup a app platform as server on Digitalocean to host my nextjs website. Currently my site is being built with ISR My question is, are the pages that are being built on runtime gets distributed to a CDN. And what about the assets, the Image component requires a node server but will that also be distributed to a CDN?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya, @renewablezip01

With App Platform, you don’t really get “CDN everywhere for anything generated at runtime” by default.

For ISR: when a page is first generated (or re-generated after the revalidate window), that generation happens on your app container (the Node runtime). The resulting HTML can be cached at the edge depending on cache headers, but it’s not the same as a guaranteed “static export pushed to a CDN like a pure static site.” So expect the first request after a revalidate to be slower (it’s doing the build), and then subsequent requests are fast while cached.

For assets: your _next/static/* (JS/CSS/chunks) are static and are typically served via the platform’s CDN/edge caching. That part is usually great.

For next/image: image optimization is done by the Node server at request time (unless you’re using a custom loader). So the first request for a given transformed image hits your app, and then it may be cached downstream if cache headers allow it. If you want “always CDN” behaviour, the common approach is to use an external image CDN (Cloudflare Images, Imgix, etc.) or put originals in Spaces + CDN and use a loader that points there.

If you share whether you’re deploying as “Static Site” or “Web Service” on App Platform (and your Next.js version), I can tell you what behaviour you can realistically expect with ISR + images on DO.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.