In SharePoint 2013, the Newsfeed relies on data cached in the distributed cache service which behind the scenes is using the appfabric cluster service. Newsfeed data is lost when you restart a server in your farm running this service without doing a graceful shutdown (http://technet.microsoft.com/en-us/library/jj219613.aspx#graceful).
Stop-SPDistributedCacheServiceInstance -Graceful Remove-SPDistributedCacheServiceInstance
Sometimes you have to restart all servers in the farm and then your newsfeed will be empty. There is a timer job that runs every 5 minutes called “Feed Cache Repopulation Job” which according to this website http://technet.microsoft.com/en-us/library/jj219560.aspx is supposed to autopopulate the newsfeed cache from the content stored in SharePoint. Our SharePoint 2013 farm is on the March 2013 PU and this job did not seem to be repopulating the cache.
The article seemed to imply you could run some powershell scripts as well to accomplish the same thing. I tried these:
Update-SPRepopulateMicroblogLMTCache Update-SPRepopulateMicroblogFeedCache
The parameter for the first one was easy, just pass in your UPA proxy. The second one also needed this proxy but it could also include an account name or a site url (http://technet.microsoft.com/en-us/library/jj219749.aspx). The wording states that when using the account name use the “user account name for the user profile service application”. I took this to mean the UPA service account. I tried that and even after waiting several hours, there still wasn’t any repopulation. So I tried the site url option passing in the mysite host url. Still nothing.
I finally figured out after using reflector on the source code that the account name it was expecting was an account of a user to repopulate THAT user’s information. I updated my script to the code below to run the Update-SPRepopulateMicroblogFeedCache for EACH user in the UPA and my newfeed cache started coming back to life!
$proxy = Get-SPServiceApplicationProxy | ? {$_.Name -eq "MySite User Profile Service"} Update-SPRepopulateMicroblogLMTCache -ProfileServiceApplicationProxy $proxy [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") $url = "https://mysite.company.com" $contextWeb = New-Object Microsoft.SharePoint.SPSite($url); $ServerContext = [Microsoft.Office.Server.ServerContext]::GetContext($contextWeb); $UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext); $Profiles = $UserProfileManager.GetEnumerator(); foreach ($oUser in $Profiles ) { if ($oUser.item("SPS-PersonalSiteCapabilities").Value -eq 14 ){ $personalurl = $url + $oUser.item("personalspace").Value Write-Host $oUser.item("AccountName").Value Update-SPRepopulateMicroblogFeedCache -ProfileServiceApplicationProxy $proxy -accountname $oUser.item("AccountName").Value #-siteurl $personalurl } } $contextWeb.Dispose()
The first time through I got a couple of errors so I added the if statement to check for the personalsitecapabilities being equal to 14. After that I got less errors but there still were a few. That’s when I tried going the site url route. I was thinking if I send in the url of a user’s personal site, that it might work better. I didn’t get any errors but it also didn’t repopulate the newsfeed for the users. Oh well…
I now believe that the siteurl parameter is to repopulate the newsfeed cache for any sites that have the newsfeed on the homepage like the new SP 2013 team site template. I know our environment doesn’t have any of these so I skipped this part. I was thinking at some point I will need to figure this out though. Hopefully it won’t involve looping through all sites in my farm but my gut says it will. If someone else has figured out a good solution, please post the powershell code in the comments. Thanks.
Update 3/29/2014:
This issue has been resolved in Service Pack 1 (SP1).