SharePoint 2007: Write an IIS Warm Up Script for a SharePoint Intranet Site

SharePoint 2007: Write an IIS Warm Up Script for a SharePoint Intranet Site

What is a Warm-Up Script

In a SharePoint production environment where IIS has been taken as hosting platform, AppPool recycling on daily basis is considered as a good practice.
But as an after-effect of AppPool-recycle, when the first user hits the sites of the corresponding SharePoint Web application, slowness is experienced. This is because of the ASP.NET's dynamic page compilation and page caching which happens when the first user hits the page after an IISRESET/AppPool Recycle. But the subsequent users will not face the problem of slowness and pages load faster.

To provide a better and faster browsing experience even to the very first user, many organizations take the help of a Warm up script which does the job of hitting the pages for the first time .In this article I am writing a sample warm-up script which can be modified and used as per requirement.

How-To write a Warm Up script

Here I am writing it in VB Script. Once the script is ready, it will be added as a scheduled task in all web servers present in the SharePoint farm. Apart from hitting the mostly visited pages, the script also logs the status into a text file based upon the http response .From the logs one can make out, if the script has run properly or not.

Section 1:
Declare variables to hold site urls.Here let's say I have got two sites to warm up.

site1="http://Web-Application Name:port/Site1/Pages/default.aspx"
'Site 2
site2="http://Web-Application Name:port/Site2/Pages/default.aspx"

Section 2:
Write a function to make HTTP calls to above urls and write the responses to a log file.In case of intranet-based applications where Windows authentication works,we need to provide userid and password of a domain account using which the GET/Post request will be sent.

Function WarmUp(url)
    On Error Resume Next
    Dim objHTTP
    Set objHTTP= CreateObject("Microsoft.XMLHTTP")
    objHTTP.Open "GET",url,False,<<userid>>,<<password>>
    If Err.Number=0 And objHTTP.Status=200 Then
        Hget=url & "has been warmed up successfully at :"& Date()&"  "& Time()
        Hget=url & "found error at :"& Date()&"  "& Time()
    End If
    Set objHTTP = Nothing
    'Section for writing into a text file
    Const FOR_APPENDING = 8
    strFileName = "C:\\scriptlogs\service_status.txt"
    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objTS = objFS.OpenTextFile(strFileName,FOR_APPENDING)
    objTS.WriteLine Hget
End Function

Section 3:
Function Call


Write these three sections in a notepad and save it with .vbs extension.

Then add this script as a Scheduled task in all web front end servers.The timing to run the script should be around 1 or 2 minutes after AppPool recycle.This is how a warmup script can be created for a SharePoint site.Hope this is helpful.
Leave a Comment
  • Please add 7 and 2 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
  • yottun8 edited Revision 8. Comment: Removed "(en-US)" in the title.

  • Jewel Lambert edited Revision 7. Comment: corrected spelling typo

  • Craig Lussier edited Revision 6. Comment: added en-US to tags and title

  • Ed Price - MSFT edited Revision 1. Comment: Tags

Page 1 of 1 (4 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Page 1 of 1 (5 items)