Skip to content

Too much redirecting when using the image optimizer on Netlify #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rayventerprise opened this issue Jul 19, 2021 · 3 comments
Closed

Comments

@rayventerprise
Copy link

rayventerprise commented Jul 19, 2021

Describe the bug
I noticed the images which use the image optimizer perform much slower when accessed on our Netlify build which I assuming is due to the redirect overhead the current setup requires.

Looks like it starts here: https://github.com/netlify/netlify-plugin-nextjs/blob/7d01abaaefe86983319438b9a6bec22b90763ce6/src/lib/steps/setupRedirects.js#L58

mydomain.com/_next/image -> mydomain.com/nextimg -> mydomain.com/.netlify/functions/whatever

Versions

  • Next.js 11

Anyway we can avoid this / cut down on the redirecting?

@rayventerprise rayventerprise changed the title Why so many redirecting on Next.js image hosting Too much redirecting when using the image optimizer on Netlify Jul 19, 2021
@ascorbic
Copy link
Contributor

Hi. The delay is unlikely to be due to the redirects, but is rather because on first load it needs to load and resize the image. It should be faster for subsequent visitors though, as the result is then cached.

@rayventerprise
Copy link
Author

rayventerprise commented Jul 21, 2021

@ascorbic What you're saying is correct, it is faster after first load however its still doing redirects to the "nextimg" after caching and the process is not an ideal speed, other reason is it just adds alot of bloat to the network tab. Is no redirect supposed to occur after initial caching and if so is there a variable I am missing perhaps? I can DM you the website specifically I am referring to.

@ascorbic
Copy link
Contributor

Fixed in edge functions #1310

serhalp pushed a commit that referenced this issue Jun 13, 2024
* test: explicitly mark test route handler as cacheable

* test: explicitly mark test route handler as non cacheable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants