Jonas Bergqvist
Feb 28, 2025
  1781
(6 votes)

Optimizely Graph Cache: The Power of "Item"

In the world of content delivery, speed is king. A high cache hit ratio is the secret weapon for delivering snappy performance and happy users. But how do you achieve that? One powerful trick lies in understanding the difference between "items" and "item" in your GraphQL queries.

The Cache Challenge: Lists vs. Specifics

GraphQL's flexibility often leads to queries fetching lists ("items"). While necessary for many scenarios, this can hinder caching. Why? Because even a list with one item requires the cache to consider potential changes to any content, leading to frequent cache invalidations.

The "Item" Advantage: Precision Caching

Enter the "item" query. When you request a single item by its unique identifier, you unlock granular, efficient caching.

How to Leverage "Item" for Optimal Caching:

  • Improve Cache Hit Ratio: Swap "items" for "item" when fetching a single entity. It's a small change with big results.
  • Unique Identifier-Driven Queries: Only use "item" when targeting a specific item via its unique identifier (relative paths, URLs, codes, etc.).

Cache hit example for query with "item"

Cache hit example for query with "items"

Practical Example

Instead of

query GetItem($relativePath: String) {
  Content(limit:1 where: { RelativePath: { eq: $relativePath } }) {
    items { Name }
  }
}

Use

query GetItem($relativePath: String) {
  Content(where: { RelativePath: { eq: $relativePath } }) {
    item { Name }
  }
}

Conclusion

Using "item" for single entity retrieval based on unique identifiers dramatically improves cache hit ratios, enhancing performance and user experience. It's a simple, powerful technique to unlock the full potential of your GraphQL cache.

Feb 28, 2025

Comments

Surjit Bharath
Surjit Bharath Mar 17, 2025 02:19 PM

5 star tip. Thanks Jonas

Please login to comment.
Latest blogs
From Prompting to Production: Optimizely Opal University Cohort and the Future of Agentic MarTech

Most organizations today are still playing with AI. They experiment with prompts, test ideas in isolated chats, and occasionally automate a task or...

Augusto Davalos | Apr 28, 2026

Six Compelling Reasons for Upgrading to CMS 13

Most software updates ask you to keep up. Optimizely CMS 13 asks something different — it asks whether your digital strategy is built for a world...

Muhammad Talha | Apr 28, 2026

Optimizely CMS 13 breaking changes: GetContentTypePropertyDisplayName

When upgrading from CMS 12 to 13, resolving property display names may not work as before. Here’s what changed.

Tomas Hensrud Gulla | Apr 27, 2026 |

Accelerate Optimizely DAM Adoption: Unlocking Business Value with Metadata Bulk Import

Accelerating Optimizely DAM Adoption How a Metadata-Driven Bulk Import Utility Unlocks Real Business Value Executive Summary For enterprises runnin...

Vaibhav | Apr 27, 2026