Configure output cache

Sitefinity .NET Core pages leverages ASP.Net Core response caching. For more information, see Microsoft documentation » Response caching in ASP.NET Core.

All of the pages that are rendered by Sitefinity .NET Core Renderer are cached with an absolute expiration of 1 minute.

You can configure the cache expiration via the standard configuration for the response cache profiles. The name of the cache profile is sitefinity.
You can configure it by editing the Startup.cs file of your .NET Core Renderer application to add the AddControllersWithViews service.
Place the configuration before calling AddSitefinity to override the behavior of the response cache.

The Startup.cs file should look like this:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Progress.Sitefinity.AspNetCore;
namespace Renderer
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews(x =>
{
x.CacheProfiles.Add("sitefinity", new CacheProfile()
{
Duration = 60 * 60, // cache the response for 1 hour
VaryByHeader = "Accept-Encoding",
Location = ResponseCacheLocation.Any,
});
});
services.AddControllersWithViews();
services.AddSitefinity();
services.AddViewComponentModels();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseSitefinity();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
endpoints.MapSitefinityEndpoints();
});
}
}
}
view raw Startup.cs hosted with ❤ by GitHub

Want to learn more?

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?