Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

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

« Go Back

Information

 
Article Number000096170
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
Attachment 
Last Modified Date5/15/2019 8:12 AM