Replies: 2 comments
-
I would consider testing how fast the request times are with the WordPress API. If they take a long time to resolve, it may be a factor in why it takes so long to build. Nevertheless, with I would instead consider |
Beta Was this translation helpful? Give feedback.
-
Looking at some metrics... Tests3 requests (not including JS assets) when a Request 1
Request 2, direct request/response times ~400ms-800ms
Request 3, direct request/response times ~400ms-1000ms
Total API response times: 800ms - 1800ms Average times for ~3 page requests... ConclusionsAlanqchen pretty mentioned the issue: There are some major slowdowns in your API endpoint response times. My guess is that your API doesn't cache requests/responses, so it treats each incoming request as unique. As a result, the data that is retrieved has to be read from the source -- either from a file or from a database. This could be one factor in slowing response times. Another factor is that the average ping times to I'd recommend using getStaticProps (gSP) over getServerSideProps (gSSP) if the data doesn't change as much... or alternatively, you could use client-side requests with skeletons, which shouldn't render the block the page and improve the UX. In addition, if you could move the API end-point to the same domain as the application then this will improve latency (utilizing Next's API routes). On the same note, your use of API routes is incorrect; any pages in the TLDR: Your API responses are very slow. The domain response is slow and the API endpoint is even slower. Either move the API within your project and/or utilize some sort of data (with filters) caching. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm learning Next.js and can't resolve a problem with slow page loading in production with pagination.
For some reason page loads for minimum of 2 seconds for only 2 posts that are called from wordpress REST API with low res image and title. App is full basic just for learning with no extra libreries.
Here is the demo page that I deployed on Vercel:
Try clicking the NEXT BUTTON to see slow performance
https://nextwp-rdm3z16jm.vercel.app/posts/test
and here is my repo for this component:
https://github.com/Thoonx/nextwp/tree/master/pages/planet // check out test.js
Does anybody know what am I doing wrong?
Is there a better way to create pagination, maybe somehow with getStaticProps?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions