---
title: Cache read-only objects
slug: cms-11/dev-docs/read-only-object-cache
docTags: 
createdAt: 2026-07-22T19:45:21.284Z
---

Most APIs in Optimizely CMS return read-only instances of objects, such as `IContentLoader.Get<TContentData>` which returns a read-only `IContent` instance.

To make changes to read-only instances, create a writable clone with the `CreateWritableClone` method, which has the following advantages:

- **Reduce memory consumption** – Threads serving Web requests get the same instance of an object, effectively reducing the number of short-lived objects created.
- **Improve performance** – Returning shared read-only instances offers better performance.
- **Cleaner architecture** – This simplifies the implementation because you cannot change an instance of an object shared with other threads.

Classes that have the read-only support implements the `IReadOnly<T>` interface, which is defined as follows:

```csharp
public interface IReadOnly {
  void MakeReadOnly();
  bool IsReadOnly {
    get;
  }
}

public interface IReadOnly<T>: IReadOnly {
  T CreateWritableClone();
}
```

The lifecycle of a typical `IContent` instance is as follows:

1. Create the `IContent` instance as mutable (which means writeable).
2. Populate the `IContent` instance with property values.
3. Call the `IReadOnly.MakeReadOnly` method to ensure that any contained objects are made read-only. The object is immutable for the remainder of its lifetime.
4. Add the object to the cache.
