We have around 18K redirects planning to move to _redirect file. But on browsing support found that only 1K is best practice. Is this still the best practice and the recommendation is still the valid one.
How does redirect caching work? - Support - Netlify Support Forums
You can still use 18k, but it would simply make your site slower. We have seen someone use 40k redirects, but response times took upwards of a second if I recall.
Edge Functions would be a better fit though. If you can come up with a logic to generate dynamic redirects, you can write a few lines of code in the Edge Function and allow it to handle the redirect for you.
Hi @hrishikesh Thanks for the reply. The architecture is we have the redirection information source and redirect url in contentful. Using Graphql we fetch the record and planned to write that in _redirect. So in this case the edge function will caall Contentful each time. Just checking with you whether the above approach is the right one. I believe we can cache the edge function response.
You can still use Edge Functions in the following manner:
- During your site’s build time, connect to your API and fetch all the redirects that you wanna generate
- Generate a JSON or some other file that you’d want to read data from (JSON would be ideal as you can bundle it with Edge Functions)
- Use that file to handle the redirects
This way, you need not poll your API for every request.