0

When my Server gets setted up again (new next-build and pm2 restart) on Deploy. The Initial Load of Images takes way to long, like 30 - 50 seconds, I guess thats because NextJS does image optimization on-demand and not on build time to prevent huge build times when there are like several hundred images.

But it can't be that I have to visit my Sites on every device width after each deploy to get image optimization and better loading results for my users?

What are your advices to that? Do you scale down all your Images with 3rd Party tools and then again on-demand with next/image? or do you ignore next/image directly? Or is there something i am missing right now?

I am using the fill property with the sizes pattern (max-width: XX) XXvw, XXvw) and my Application is running with next start on my own hosted server, I do not use next export to generate a static site.

Till now I tried several things with next/image to shrink down my Image sizes. using fill and sizes as mentioned, but the problem stays the same, on-demand image providing is in the worst case 50 seconds. And I guess thats because the User is requesting an certain image -> nextJS does optimize it -> returns it back to user. WHEN the first page load is executed, every other user benefits from it, because nextJS already have those compressed images.

Samet Conrad
  • 201
  • 1
  • 5
  • 1
    Did you look at https://stackoverflow.com/questions/66637391/next-images-components-are-too-slow-to-appear? – James Apr 09 '23 at 21:52
  • @James wow that does improve on-demand by quite ALOT, i have missed that completly thought sharp is just for `next export` usage. Thanks, i will dig more into it to solve my now way smaller problem. – Samet Conrad Apr 09 '23 at 22:05

1 Answers1

0

Question solved by James in the comments of the question itself.

Samet Conrad
  • 201
  • 1
  • 5