NetCore Reports Caching and load balancers

Stimulsoft Reports.WEB discussion
Post Reply
emanuelv
Posts: 20
Joined: Fri Sep 13, 2019 5:46 pm

NetCore Reports Caching and load balancers

Post by emanuelv »

Hello,

It seems as though using StiServerCacheMode.None causes reports to go into an infinite loop loading again and again. Our applications are deployed on a load balancer across two servers. Each alternating request is routed to the other server and vice versa. So the default cache mode causes the report to be cached on the alternate server every time. So whenever I try to do a drill-down from a dashboard chart, it just reloads because it can't find the cached report... because it's on the other server. So it never actually drills down. If I take down one of the servers on the load balancer, everything works because it is all coming from one server.

I attempted to disable caching using the StiNetCoreViewerOptions() Server.CacheMode = StiServerCacheMode.None. However, this causes the initial dashboard page to continuously reload in an infinite loop. Almost as if it retrieves the report, doesn't load it into the cache, but then it tries to retrieve it from the cache, which isn't there, so it fetches the report again.

This is very easy to reproduce using the Stimulsoft DashboardSalesByMonth demo (https://demo.stimulsoft.com/#Net/DashboardSalesByMonth). I published this report without modifying anything from the Designer using the .NET Core and Angular configuration.

Then, in the ViewerController.cs, I disabled caching in the /api/viewer Get() method like this:

Code: Select all

[HttpGet]
public IActionResult Get()
{
	// Setting the required options on the server side
	var requestParams = StiNetCoreViewer.GetRequestParams(this);
	if (requestParams.Action == StiAction.Undefined)
	{
		var options = new StiNetCoreViewerOptions()
		{
			Server =
			{
				CacheMode = StiServerCacheMode.None //Disable cache
			}
		};
		return StiNetCoreViewer.GetScriptsResult(this, options);
	}
	return StiNetCoreViewer.ProcessRequestResult(this);
}
Then run the application in IIS Express and navigate to the dashboard page from the side menu. The report will load over and over in an infinite loop. Is there an additional setting I need to set if I disable cache mode? Or how can I make it use something like browser cache instead of server cache?

Thanks!
-Emanuel
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: NetCore Reports Caching and load balancers

Post by Lech Kulikowski »

Hello,

As you do not use caching, is needed to send report object in each action. Please check the following code:

Code: Select all

[HttpPost]
public IActionResult Post()
{
    var report = new StiReport();
    report.Load(StiNetCoreHelper.MapPath(this, "Reports/Christmas.mrt"));

    var requestParams = StiNetCoreViewer.GetRequestParams(this);
    switch (requestParams.Action)
    {
        case StiAction.GetReport:
            return StiNetCoreViewer.GetReportResult(requestParams, report);

        default:
            return StiNetCoreViewer.ProcessRequestResult(requestParams, report);
    }
}
Thank you.
emanuelv
Posts: 20
Joined: Fri Sep 13, 2019 5:46 pm

Re: NetCore Reports Caching and load balancers

Post by emanuelv »

Hi Lech,

Do you have any caching recommendations other than no caching for load balancers in which every other request is sent to an alternating server? Paginating through larger reports becomes a bit slower when loading in all of the data with every request.

Thanks!
-Emanuel
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: NetCore Reports Caching and load balancers

Post by Lech Kulikowski »

Hello,

Unfortunately, we can not provide more recommendations for balancers.

Thank you.
Post Reply