Configuring Report caching
Our sample projects and report templates can help you learn the basics of working with our products.Caching keeps a rendered report on the server between requests, so paging and exporting do not rebuild it every time. A
Implement a cache helper. Override how a report is saved, loaded and removed — here to files:
How it works. The viewer stores and retrieves the report through the helper, so a single render serves paging, exporting and printing across requests.
StiCacheHelper controls where it is stored.Implement a cache helper. Override how a report is saved, loaded and removed — here to files:
public class StiFileCacheHelper : StiCacheHelper
{
public override void SaveReport(StiReport report, string guid)
{
var packed = guid.EndsWith(GUID_ReportTemplate)
? report.SavePackedReportToString() : report.SavePackedDocumentToString();
File.WriteAllText(CachePath(guid), packed);
}
public override StiReport GetReport(string guid) { /* load packed report/document */ }
public override void RemoveReport(string guid) { /* delete the cache file */ }
}Register the helper on the viewer.StiNetCoreViewer.CacheHelper = new StiFileCacheHelper();SavePackedReportToString/SavePackedDocumentToString— serialize the template or the rendered document for storage.StiNetCoreViewer.CacheHelper— plug in your helper; the default caches in session, this variant caches to files.
How it works. The viewer stores and retrieves the report through the helper, so a single render serves paging, exporting and printing across requests.