When I publish or restart my web app it loads very slowly the first time, then when I refresh with F5 it is ok again. what could it be?

- 3,199
- 1
- 16
- 21
-
If it's a web app, this is normal, as things get loaded/cached. – David Makogon Jul 18 '18 at 01:46
1 Answers
It will happen with Windows Azure Websites. Windows Azure Websites are running in shared pool of resources and uses the concept of hot (active) and cold (inactive) sites in which if a websites has no active connection for x amount of time, the site goes into cold state means the host IIS process exits. When a new connection is made to that websites it takes a few seconds to get the site ready and working. Depend on how your first page code is, the time to load the site for the first time varies.
The IIS takes a while to boot up after you upload new files to the app container. Application Initialization module and deployment slot swap also takes several time.
So the first page hit after you've updated the app will be slower. Also Azure Web Apps get dehydrated after a period of inactivity. This also causes the first page hit to be very slow if the page hasn't been accessed in a while.
To combat this, in the Application Settings
for the web app, you can find a setting called Always On, which basically pings your page every couple minutes to keep the app hydrated and responsive.
For more details, you could refer to this blog.
As juunas said, you could also use Razor view pre-compilation
to speed up the initial loads. Otherwise the app must compile the views at run-time when they are first rendered.

- 18,968
- 1
- 20
- 30
-
Since OP is also using ASP.NET MVC 5 (judging by the tags), they can also use Razor view pre-compilation to speed up the initial loads. Since otherwise the app must compile the views at run-time when they are first rendered. – juunas Jul 18 '18 at 05:48
-
A mention about Application Initialization module and deployment slot swap would be good too ;) – juunas Jul 18 '18 at 05:48
-
-
-
I tried the precompile option, It didn't made any difference. I knew about the Always On setting but I didn't considered it before because the web app started doing this recently. Thank you – The Memebot Jul 18 '18 at 17:48
-
After you tried the [precompile during publish](https://stackoverflow.com/questions/22018962/precompile-during-publish-for-azure-web-services) option, first page open performance then seems much better. But it still need to some time to load page and cache page. – Joey Cai Jul 19 '18 at 03:24