Why does an ASHX in a virtual directory load instantly when a proper SP page takes a while to load after a restart?
The ASHX is using the SP Object Model to get and display SP data.
By proper SP page I mean
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
Each time you restart IIS, sharepoint (.net) forces a recompile of the application. This takes a while for the first user who hits the site.
Some options are:
Build a warmup script that fires on a scheduled task calling an http request to sharepoint a forcing the site to compile.
Create a timer service in sharepoint that iterates through the site collections and forces them to compile.
Increase the timeout on your app pool recycling (not too sure about this one but I vaguely remember reading it somewhere. )
Hope this helps.
An ASHX focuses solely on returning simplified text output (usually) and has no dependent resources, like large JS, CSS or image files nor does make any additional calls back to the server once the results are sent to the consumer. If you really want to understand the difference, fire up the Network Monitor option in your browser or just watch a Fiddler capture of the two sessions. The differences would likely surprise you.
It is also possible that the page in question is issuing a non-cached query of some complex data source which would further slow down the render time. If there are a lot of web parts on the page, that would slow it down too.