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:
- In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
- In the tree view on the left, expand System » Output Cache Settings.
- Select or deselect the Enable output cache checkbox.
- Save your changes.
Create and edit OData output cache profiles
Perform the following:
- In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
- In the tree view on the left, expand System » Output Cache Settings » Web Services Cache Profiles.
- 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:
- Navigate to Administration » Settings » Advanced.
- In three on the left, expand WebServices » Routes » <YourRouteName> » Services » <YourServiceName>.
- 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.
- 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.