Feedback
Did this article resolve your question/issue?

   

Article

Sitefinity not caching pages visited by the Warmup module or cached by warmup scripts

« Go Back

Information

 
TitleSitefinity not caching pages visited by the Warmup module or cached by warmup scripts
URL NameSitefinity-not-caching-pages-visited-by-the-Warmup-module
Article Number000134224
EnvironmentProduct: Sitefinity
Version: 10.1, 10.2, 11.x, 12.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
A custom warmup script that runs each day to visit each of the pages of the site and put them into the site cache doesn`t cache the site pages. When the page that should be already cached by script or Sitefinity`s warmup module is visited by the browser it is not taken from the cache.

Warmup module doesn`t cache the warmed up pages.
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
The site has Global.asax file which includes the session state handlers.
protected void Session_Start(object sender, EventArgs e)
{
}

protected void Session_End(object sender, EventArgs e)
{
}
Those handlers trigger the generation of ASP.NET_SessionId cookie in the browser.
The generated session cookie threats the browser`s request to the page as a request that will not be taken from the cache. Thus the presence of ASP.NET_SessionId cookie generated new cache for a given page. The cache for the same page that was already created via Sitefinity Warmup module or any custom script that triggers cache on a page will be ignored.
 
Resolution
Remove the session state handlers from Global.asax
protected void Session_Start(object sender, EventArgs e)
{
}

protected void Session_End(object sender, EventArgs e)
{
}
Build/compile the site after this and pages cached with either Sitefinity`s Warmup module or custom scripts will pre-cache the site.

In case the site uses Session state then warmup the site via a script that:
1. the page http://site.com/forms is requested once to get the session cookie.
2. The page is requested again to cache it
#specify the url of a page from your site whcih contains an MVC widget
$url = "http://site.com/forms"
#create a CookieContainer to store the cookie in
$cookiejar = New-Object System.Net.CookieContainer
$webrequest = [System.Net.HTTPWebRequest]::Create($url);
$webrequest.CookieContainer = $cookiejar
$response = $webrequest.GetResponse()
$cookies = $cookiejar.GetCookies($url)

#in the basic scenario we get only 1 cookie back and that's the "ASP.NET_SessionId"
#so you can do sth. like:
# $cookie1=$cookies[0]
#however if you have more cookies you can look for it by name
$cookie1 = New-Object System.Net.Cookie
foreach ($cookie in $cookies) {
if ($cookie.name = "ASP.NET_SessionId") {
$cookie1 = $cookie
}
}

#emulate Chrome request
[System.Net.HttpWebRequest] $reqChrome = [System.Net.HttpWebRequest]::Create("http://site.com/forms")
$reqChrome.Method = "GET"
$reqChrome.Timeout = 600000
$reqChrome.UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
#setting the CookieContainer to the one which already contains the cookie
$reqChrome.CookieContainer=$cookiejar
[System.Net.HttpWebResponse] $resultChrome = $reqChrome.GetResponse()
#you can use the below for testing pur[pose to observe if Set-Cookie is present #in the response headers
#Write-Output $resultChrome.Headers
#write-output $resultChrome.GetResponseHeader('Set-Cookie')
$resultChrome.Close()
#Remove-Variable $resultChrome
Workaround
Notes
Last Modified Date5/15/2019 8:12 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.