nextjs.org/learn/foundations/how-nextjs-works/cdns-and-edge
10 Users
1 Comments
49 Highlights
2 Notes
Tags
Top Highlights
CDNs store static content (such as HTML and image files) in multiple locations around the world and are placed between the client and the origin server.
Similar to CDNs, Edge servers are distributed to multiple locations around the world. But unlike CDNs, which store static content, some Edge servers can run small snippets of code.
Next.js, since pre-rendering can be done ahead of time, CDNs are well suited to store the static result of the work - making content delivery faster
which store static content, some Edge servers can run small snippets of code.
In the case of a Next.js application, your application code can be distributed to origin servers, Content Delivery Networks (CDNs), and the Edge.
As we discussed earlier, the server refers to the main computer that stores and runs the original version of your application code.
geographically
CDNs store static content (such as HTML and image files) in multiple locations around the world and are placed between the client and the origin server
unlike CDNs, which store static content, some Edge servers can run code
both caching and code execution
Origin Servers
main computer that stores and runs the original version of your application code
When an origin server receives a request, it does some computation before sending a response.
The result of this computation work can be moved to a CDN
Content Delivery Network
store
static content (such as HTML and image files)
When a new request comes in, the closest CDN location to the user can respond with the
cached result
reduces the load on the origin
Toughts & Comments
Bilal Siddiqui
In the context of Next.js, CDNs (Content Delivery Networks) refer to the networks of servers that are used to distribute static assets, such as images, stylesheets, and JavaScript files, to users around the world. CDNs can help to improve the performance and reliability of web applications by caching content closer to users and reducing the load on the origin server. Next.js has built-in support for using CDNs to serve static assets. You can configure Next.js to automatically optimize and serve your static assets using a CDN by setting the assetPrefix property in your next.config.js file. For example, you can set the assetPrefix to a URL that points to a CDN, like this: java Copy code module.exports = { assetPrefix: 'https://cdn.example.com' } This will cause Next.js to prefix all URLs for static assets with the specified URL, which will be used as the base URL for the CDN. In addition to using a CDN for static assets, Next.js also supports server-side rendering of dynamic content, which can further improve the performance and SEO of your web application.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.