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 /pages/default.aspx.


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.

  • My ASHX files are not returning simplified text output. The answer here lies on the server side and not on the client side. The key words in my question are after a restart. SharePoint is notoriously slow for the first visitor of the day to the site. This slowness doesn't happen for ASHX files. – iambriansreed Oct 25 '13 at 20:20
  • If you have regularly scheduled server restarts, it is recommended that you use warmup scripts to call and pre-load your SharePoint sites so that the first user to the site does not encounter that slowness. That aside, the presence of content in /Pages/ means that SharePoint must also spin up the Publishing infrastructure which often includes server-side calls to other libraries (i.e. /Style Library/, /_catalogs/, etc). It also needs to instantiate a master page, a page layout, X web parts and pull in all of their respective server-side includes. – Dave Wise Oct 25 '13 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.