When you make changes to content in Hygraph, stale content existing on the cache is invalidated. Upon the next user's request, the content is now served from the origin instead and cached again.
This ensures that the content served to the user is fresh and consists of all changes made by the editorial team.
Prior to this update, Hygraph invalidated the entire cache when any changes were made to the content.
With the new Partial Cache Invalidations, instead of invalidating the entire cache, Hygraph now invalidates the model or stage at which the content changes were made.
What does this mean for you?
Higher performance and lower latency! More content is served from the cache rather than the origin, and downstream applications load faster.
All of this is highly useful if you have large volumes of traffic and make frequent changes to content.
The bottomline; you can build faster applications/websites, which leads to higher satisfaction and engagement amongst your end-users.
This article discusses in detail what Partial Cache Invalidation is, and how you can benefit from this in Hygraph.
Note: Partial Cache Invalidation is only offered on the new high-performance read-only endpoint. To learn more about configuring endpoints and caching, visit our documentation.
#What is Partial Cache Invalidation?
Content residing on your cache doesn't automatically update itself. If any changes are made to the content in the CMS, these would not be reflected in the content on the cache.
Cache invalidation refers to the process of declaring this stale content on the cache as invalid. This means that the stale content would no longer be served to a client upon request, and the new and updated content will be served from the origin instead.
Cache invalidation is of two types:
- Full Cache Invalidation: All content on the cache is invalidated.
- Partial Cache Invalidation: Only a portion of the content on the cache is invalidated.
#Cache invalidation offered by Hygraph
Hygraph offers two endpoints for serving your content; the high-performance read-only endpoint and the regular read & write endpoint.
High-performance read-only endpoint
The high-performance read-only endpoint now offers model-and-stage-based partial cache invalidation.
This means that any changes made to a model, will only invalidate the content cached for that model. The content for other models (if not requested in the same query) will not be invalidated.
For example, changes made to a content entry of the model "product description" will only invalidate entries cached for the "product description" model and not others; "price", "assets", etc. However, if another model such as "price" is referenced within the "product description" and requested within the same query, only then content for the "price" model will be invalidated.
Similarly, any changes made to content on the "draft" stage, will not invalidate the cache for content on the "published" stage.
- Higher cache hit ratio: Since the entire cache is not invalidated, content is more often served from the cache than the origin. This makes downstream applications/websites load faster.
- Lower latency: The high-performance read-only endpoint offers low latency, and the new partial cache invalidation further improves this.
- Improved User Satisfaction: Websites/applications load faster for your end-users, which leads to improved engagement and user satisfaction.
Note: Writes are not allowed to our High performance endpoint. This means you should use the regular read & write endpoint endpoint for mutations.
Regular read & write endpoint
The regular read & write endpoint offers full cache invalidation. This means that any changes made to the content will invalidate the entire content on the cache.Read the documentation
The roll-out of advanced caching capabilities is part of our vision to empower enterprises with the tech needed to build high-performance modern digital products.
Hygraph handles all cache management for you, without any code changes on your end.
We recommend going through our documentation to learn more about the caching capabilities in Hygraph and how to best set up the project according to your needs.
Nevertheless, do let us know what you think of the new Partial Cache Invalidation feature by sharing your feedback in our Slack Channel.