Configure OData output cache

Overview

Sitefinity CMS output cache implementation guarantees that your sites perform optimally and can handle peaks in user load. Using distributed output cache enhances this effect further, because items, stored in output cache, remain available even during website restarts or IIS AppPool recycles.

Output cache is supported for OData services. The cache is supported only for unauthenticated, frontend requests. OData output cache works the same way as the standard output cache – it can be enabled and disabled, and it is configurable via cache profiles.

Enable and disable OData output cache

You can enable and disable OData output cache for the whole Sitefinity CMS instance.
Perform the following:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
  2. In the tree view on the left, expand System » Output Cache Settings » Output cache web service.
  3. Select or deselect the Enable output cache web service checkbox.
  4. Optionally, enter an Authentication key.
    By default, only authenticated users in the Administrators role can send requests to the output cache web service. If you want to enable other users to access the service endpoint, you can configure an authentication key.

    Afterwards, you pass the value of the authentication key when making calls to the service. You pass it as HTTP header with key SF_OUTPUTCACHE_AUTH.

  5. Require Https for all requests.
    By default, this setting is enabled. it controls whether all web service calls are redirected to https:// or not.

    IMPORTANT: The setting is important to the security. Unless, your specific use case scenario requires that you make the web service calls to the output cache web service over http://., keep this checkbox checked.

  6. Save your changes.

Create and edit OData output cache profiles

Perform the following:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
  2. In the tree view on the left, expand System » Output Cache Settings » Web Services Cache Profiles.
  3. To create a new profile, click Create new and fill out the following and save your changes:
Setting Description
Name

Defines the programmatic name of the profile. 
This is the name used to access the profile.

Location

Specifies the location of the cached HTTP response content. 
You can choose one of the following values:

  • None
    No cache profile is applied, the client sends new requests and the server generates content for the response on every request
  • Server
    Cache is applied only on the server, the client still sends new requests.
  • Client
    Cache is applied only on the client, the server generates content every time there is a request to it.
  • ServerAndClient
    Cache is applied both on client and on the original (hosting) server, that is, not just any proxy server
  • Any
    Cache is applied on the browser client (where the request originated), on a proxy server and any other server participating in the request (where the request was processed)
Duration

Specifies the maximum time in seconds that the fetched response is allowed to be reused from the time of the request.

Sliding expiration
Indicates whether the expiration time is reset on every request.
Client Max Age

Specifies the maximum time in seconds that the fetched response is allowed to be reused from the time of the request.

Corresponds to the max-age directive of the cache-control header. If this value is not specified, the system uses the client caching and the Duration property sets the client cache max age.

Proxy or Max Age

This setting corresponds to the s-maxage cache-control directive and it explicitly applies to proxy servers.

The proxy max age property overrides the max-age directive and expires the header field when present.

Configure OData output cache per route

To configure specific route:

  1. Navigate to Administration » Settings » Advanced.
  2. In three on the left, expand WebServices » Routes » <YourRouteName> » Services » <YourServiceName>.
  3. In Output cache profile field, enter the name of the profile that you want to apply to this specific route.

    NOTE: If the you leave the field empty, the system uses the default output cache profile.

  4. Save your changes.

Cache invalidation

Output cache increases your website performance. In some cases, however, you might want to have a mechanism for on-demand invalidation of distributed output cache.

For example, when the development team applies a change to a template and deploys this to production. The deployment causes an application restart and, in case of in-memory output cache, the cached HTML of the website pages is invalidated, so that the newly deployed changes become visible immediately. With distributed output cache, the application restart does not affect the output cache of pages, therefore you may not see the newly deployed changes to take effect, until you manually publish the page or template, where your widget is placed, or wait for cache to expire.

To assist in situations, where distributed output cache must be invalidated on-demand, Sitefinity CMS exposes a web service for manipulating output cache. By calling the /restapi/cache/clear endpoint, website administrators, or authorized users can effectively purge the distributed output cache.

Use the output cache web service

The output cache web service is available at the /restapi/cache endpoint. It supports POST requests to the service /restapi/cache/clear method. Calling the method invalidates all output cache items stored in distributed cache.

NOTE: Clearing all output cache items on a production website might result in a significant performance impact. Avoid doing this if your site is under heavy load.

If you have configured an Authentication key, you can pass the key as an HTTP header to the request. The header key must be SF_OUTPUTCACHE_AUTH, and its value - the Authentication key value.

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?

Next article

Configure exceptions