ActiveReports 18 .NET Edition
Developers / Create Applications / Js Viewer Application / Caching Reports
In This Topic
    Caching Reports
    In This Topic

    Caching reports is a great technique to improve the performance of report rendering and is extremely beneficial for large reports with an infrequent change of data, like periodic reports that generate monthly or weekly.

    The Js Viewer backends read a report as many times as required. However, sometimes you may need to cache the report as demonstrated in the example below.

    Index.cshtml
    Copy Code
    var cache = new MemoryCache(new MemoryCacheOptions { SizeLimit = 10000 });
    settings.UseCustomStore(reportId =>
        cache.GetOrCreate(reportId, entry =>
        {
            entry.SetSlidingExpiration(TimeSpan.FromSeconds(30));
            return new PageReport(new FileInfo(Path.Combine(@"C:\Reports", reportId)));
        });