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
slow server response time in dynamic routes when using Angular SSR #55021
Comments
Without a reproduction, it will be impossible to diagnose and verify this report. For example, we don't know what the difference in the two routes is - perhaps the route with a slug is waiting on a database call to load. |
You can find an example in blog section of this website: Here are the codes of the blog.routes.ts file:
In order to prevent high-traffic pages from loading slowly, I had to manually enter some slugs, but I left the rest dynamic. I passed the parameter for the API call in manual routes through data. This is a part of the code from the blog-article.component.ts file:
The initial document load time for this link parsouatravel.com/blog/aurora-borealis (the route I entered manually) is only 50 ms. However, the initial document load time for this link that I did not enter manually parsouatravel.com/blog/the-lion-s-rock is 1.03 s The speed of retrieving data from the database and API call does not make much difference. |
@majidkhaleghian, kindly provide a runnable minimal reproduction. You can read here why this is needed. A good way to make a minimal repro is to create a new app via |
Closing due to lack of a runnable reproduction. If the problem still exists in your application, please open a new issue and follow the instructions in the issue template. |
@majidkhaleghian Did you find a solution for your issue? We're experiencing the exact same delay using the "**" wildcard route for the same usecase as yours (loading dynamic slugs for a cms). |
Unfortunately, I couldn't find a solution. The only way to eliminate the delay is to define all routes statically. This can be done either in the blog.routes.ts file or through routes.txt. |
Ok we are trying to create a minimal reproduction to report an issue. |
Likely your are using prerendering for non-parameterized routes. |
Which @angular/* package(s) are the source of the bug?
platform-server
Is this a regression?
Yes
Description
When I used Angular SSR, some pages were loading with a very high delay. At first, I couldn't figure out where the problem was and I did a lot of checking.
Finally, I realized that the delay occurs when a route has a param. For example, the initial fetch of other pages took 10ms, but pages with a route with a param took close to 1s.
Suppose we have a blog and the route is as follows:
blog/:slug
In this case, for example, the page blog/my-article will load with a delay of close to 1s..
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: