N
Nuxt4w ago
Jelmer

Big performance regressions happing after adding large amount of redirects (3000+) inside routeRules

Hi! Is anyone here maybe familiar with big performance regressions happing, after adding a very large amount of routeRules entries (3000+ redirects) to nuxt.config.ts ? I see this happening in my project. I am trying to see why it is happing. Every Nuxt page has about a ~10x decrease in initial HTML response time after adding the redirects. As a test, a blank Nitro application configured with the same routeRules does not show this performance regression. Has anyone experienced this?
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Jelmer. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I can offer some insights into your question about performance regressions after adding a large number of redirects to routeRules in Nuxt. While there isn't a direct mention of performance issues with 3000+ redirects, there are some relevant points to consider: 1. Route Rules and Performance: Nuxt's route rules feature is designed to allow different caching rules per route and decide how the server should respond to requests. However, the documentation doesn't mention any specific limitations or performance considerations for a large number of rules. Docs > Guide > Concepts > Rendering Modes > Hybrid Rendering 2. Recent Improvements: There have been recent improvements to how Nuxt handles route rules. For example, a fix was implemented to handle external redirects from routeRules fix(nuxt): handle external redirects from routeRules. This suggests that the Nuxt team is actively working on optimizing route rules handling. 3. Potential Causes: The performance regression you're experiencing might be related to how Nuxt processes these rules during the initial page load. Since you mentioned that a blank Nitro application doesn't show this regression, it's possible that the issue is specific to how Nuxt integrates these rules with its routing system. 4. Possible Workarounds: While not directly addressing your issue, you might consider exploring alternative approaches: a. Use Netlify or Vercel's native redirect rules if possible, as mentioned in the documentation: "Whenever possible, route rules will be automatically applied to the deployment platform's native rules for optimal performances (Netlify and Vercel are currently supported)." Docs > Guide > Concepts > Rendering Modes > Hybrid Rendering b. If the redirects are for legacy URLs, consider handling them at the server level or through a reverse proxy instead of within Nuxt. 5. Reporting the Issue: Given that this seems to be a significant performance regression, it would be valuable to report this issue to the Nuxt GitHub repository. Provide a minimal reproduction of the problem, including: - The number of redirect rules causing the issue - Performance metrics before and after adding the rules - Your Nuxt version and configuration Docs > Community > Reporting Bugs provides guidelines on how to effectively report bugs to the Nuxt team. In conclusion, while the knowledge sources don't provide a direct solution to your specific problem with 3000+ redirects, they suggest that this is an unusual case that might require attention from the Nuxt core team. Consider reporting the issue and exploring alternative methods for handling such a large number of redirects in the meantime. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@958735111208202260> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?