Wednesday, August 8, 2012

Webpage cache warmer with Powershell


Have you ever needed to cache web pages after a web server reboot?  Here is a great little PowerShell script that can be added to the start-up script of a server.  This is also great for getting SharePoint pages cached after a reboot.

##############################################################
##############################################################
##############################################################
#
#     Open a list of webpages to warm the web server cache
#
##############################################################

# Created Date: 8/6/2012
# Created By: Jim Bennett

##############################################################
##############################################################
##############################################################


#Variables

#Enter a comma separated list of webpages to hit
$WebpageList = "http://www.google.com","http://www.capstonebi.com"


$WebpageList | ForEach-Object {
      Write-Host "Opening page: $_" -ForegroundColor Yellow -nonewline
      $temp = [System.Math]::Round((Measure-Command {(new-object net.webclient).DownloadString($_)}).totalmilliseconds)
      Write-Host " (Opened in $temp milliseconds)" -ForegroundColor Yellow
}

No comments:

Post a Comment