'How to improve page speed in next js
We are using Next JS as a frontend framework and Wordpress for CMS. We are fetching all headers and footers data from wordpress through a graphql query which is taking huge time to generate the HTML on server side and which leads and huge delay on every page rendering.
What we can do to increase the page speed. We tried redux as well as context api but nothing works great as we are fetching the wordpress on getServersideProps or getStaticProps.
Any suggestions. Thanks in advance.
Solution 1:[1]
It's very unlikely that you have so many dynamic data that you can't make a static build for header, footer, etc.... You should use SSG getStaticProps and use SSR or client-side fetch only for those kinds of dynamic data that can't be made static. Consider that you also have ISG feature, and you can revalidate each static page when you need to update data, but the user will always have an almost zero loading time when that job is done at build time.
https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cesare Polonara |
