How To Fix Distributed Cache in Sharepoint 2013 Problem?

SharePoint 2013 Distributed Cache error

Is your SharePoint 2013 application is performing so poorly and showing Distributed Cache error? The reason behind the distributed cache SharePoint 2013 error is fetched that a bug in an AppFabric.

AppFabric is used to save different information in SharePoint 2013 installation but today users are facing problems with the Logon Token Cache (DistributedLogonTokenCache).

So, if you are struggling with the distributed cache SharePoint 2013 error, then read the article to follow the fixes given.

What is Distributed Cache SharePoint 2013?

Distributed Cache is utilized for quick data recovery and storing data in memory. It does not have a dependence on the databases in SharePoint 2013 Server.

Well, this is generally used for facilitating Search and new social features in SharePoint 2013, because both of them require fast access to huge amounts of information.

What is the Distributed Cache Problem?

When the client’s homepage was being loaded, it has been noticed that “401 – Not Authorized” errors occurring for simple things like CSS or JS files, often multiple times in each of the files before a successful request was made to retrieve it.

When the reason for this error is searched a large number of other errors in the “DistributedCache” category founded, theses errors are:

  • Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage ‘DistributedLogonTokenCache’ – Exception ‘Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode<ERRCA0018>:SubStatus<ES0001>:The request timed out.
  • Unexpected error occurred in the method ‘GetObject’, usage ‘Distributed Logon Token Cache’ – Exception ‘Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode<ERRCA0018>:SubStatus<ES0001>:The request timed out.

This actually happens because when a user successfully logs into the application, a login token is get saved in the Distributed Logon Token Cache, which allows it to easily checked for future authentication. A bud with AppFabric, don’t allow the cache to remove out any old entries.

So with every request and login cache just grows heavy. Sometimes, it becomes so large that accessing that is too time taking. And when the request time to get a logon token exceeds so much, then the request is counted as authorized which explains the 401 errors. When SharePoint receives 401 errors, it is to re-authenticate the user.

How to Fix Distributed Cache SharePoint 2013 Error?

Solution 1 – Update AppFabric on all Servers 

As an official solution, you can update AppFabric on all servers and update the DistributedCacheService.exe.config configuration file on all servers to include the backgroundGC key.

It is important to place the appSettings node in between the configSections and dataCachConfig elements.  This update will fix the bug and enables garbage collection which allows AppFabric to delete old entries from the cache, and maintain its size, which in turn ensures that requests will finish within the limited time period.

After updating each server, perform the following steps:

  • On all affected servers restart the AppFabric Windows Service.
  • Restart the Distributed Cache SharePoint Service on all affected servers.
  • Run iisreset on all servers.
  • If by updating AppFabric does not entirely stop Distributed Cache errors from appearing then you can update the timeout values for the Distributed Cache. If you don’t perform this updation step then it will not remove your time gap and the cache will grow larger and Distributed Cache errors will return again.

While the Timeout properties are having a higher priority, you may observe errors in ULS referencing buffer size or connection failures. In that case, it’s also important to increase the buffer size and max connections.

Once the updates to the Distributed Cache get over, reset the AppFabric Windows Service and Distributed Cache SharePoint Service on all affected servers.

If the above-given solution won’t work for you to fix Distributed Cache SharePoint 2013 problem then try the next solution.

Solution 2 – Forcefully delete the Distributed Cache

Many users confirmed that deleting the Distributed Cache instance forcefully works for you to fix the Distributed Cache error in SharePoint 2013.

Follow the below given commands to delete it:

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName –and ($_.server.name) -eq “SP2013App”}
$serviceInstance.Delete()
Add-SPDistributedCacheServiceInstance

Solution 3 – Try Removing & Adding DistributedCache

If deleting the Distributed Cache won’t works for you then remove the SharePoint service on localhost

Run the given commands to do so:

Stop-SPDistributedCacheServiceInstance –Graceful Remove-SPDistributedCacheServiceInstance$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}$serviceInstance.delete()

Now after removing the Distributed Cache try adding DC Instance:

$SPFarm = Get-SPFarm
$cacheClusterName = “SPDistributedCacheCluster_” + $SPFarm.Id.ToString()
$cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local
$cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName);
$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq $env:computername}
$serviceInstance.Delete()
Add-SPDistributedCacheServiceInstance

Hopefully this works for you to fix distributed cache SharePoint 2013 problem but if not then follow the automatic SharePoint Repair Tool.

Easy Solution to Fix SharePoint 2013 Distributed Cache Problem

The above-given steps will make your SharePoint database error-free, but if you are unable to get rid of error messages it means that SharePoint is having serious issues and you need to apply the professionally designed SharePoint Repair Tool.

This tool is able to fix all your issues that occurred in SharePoint 2013. It effectively scans the damaged database files and repairs it to recover inaccessible objects in MDF database files. With this tool, users can also retrieve SharePoint databases like tables, indexes, documents, labels, and stored procedures from inaccessible MDF files.

This software is incorporated with a simple and rich graphical user interface to offer easy SharePoint recovery.


Steps to Run the SharePoint Repair Tool

  • Firstly, download, install and launch the SharePoint Recovery Tool.
  • The interface screen displays two options to recover SharePoint data: ‘Complete Repair‘ and ‘Document Recovery‘. Select as per your requirement.

  • If you choose ‘Complete Repair‘, the screen will show the options for selecting and searching SQL Server (.MDF) files. Click on ‘Browse‘ to select a SharePoint database for repair.
  • If you do not know the actual path of the database which you want to repair, click on the ‘Find‘ to locate the MDF file in a specific drive.
  • After selecting the desired file initiate the scanning process.

  • After finishing the scan, the software would generate a tree of all SharePoint database tables and will display it in the left pane. You can select the table in the tree and can have the entire preview in the right pane. Then click on ‘Repair‘ to begin repairing for the selected database.
  • After clicking on ‘Repair‘, this dialog box will appear. Specify the SQL Server name or Instance name and the desired destination path.
  • Click on the ‘Browse‘ option to choose the destination path. And select the ‘OK‘ button.
  • Once this process gets completed, you would find a dialog box that displays this message ‘Recovered file saved at the desired location.” This shows that Recovery Process has successfully completed’.
  • Select the ‘OK‘ button.
  • You would find another dialog box that asks whether you want to attach the repaired database to the web application. If you click on the ‘Yes‘ button, the above dialog box will be displayed.
  • In the web application type URL, the name of the corrupt database and SQL Server Instance name.
  • Then select the ‘OK‘ button and proceed.
  • When the process gets finished, you would be able to access the repaired database by opening the web application.

Conclusion

Distributed Cache is the latest and important component in the SharePoint server 2013. But many times this start causing issues and errors and users start facing problem in using SharePoint 2013.

So, here in this article, I listed the best possible fixes to get rid of the SharePoint 2013 Distributed Cache.

Follow the solutions given accordingly and check which one works for you. But if the manual solutions won’t work for you, then feel free to use the automatic SharePoint Repair Tool.

If you have any other queries or suggestions, then share it with us on the Facebook page. Also, if you like this article, then share it with the users going through the same issue.