You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TTFB is still terrible (although it is miles better than Prismic) and since we serve content that won't change very much, we can leverage the existing GraphQL ecosystem to cache them aggressively.
The idea
Change the GraphQL client from current poor man's implementation to @urql/core and cache them using Graphcache since we know a lot of data can appear from various places (usually blocks).
Caching customization
Cache ArticleRecord by slugs
We rarely use ID value for ArticleRecord but it is without a doubt the most requested resource on the website. I propose to cache them by the pair of locale and slug which is unique enough to cache.
We can do this by leveraging the Local Resolvers feature of urql.
Instant invalidation
In combination with Dato's webhook feature, we can make Urql invalidate certain entities as soon as it gets updated. It can be done by using cache.invalidate.
Persistent cache
We have to rely on some sort of external persistent state because Vercel's Remix hosting is essentially a Serverless Function. We could do this by Upstash's Redis hosting with custom cache options of Graphcache.
Server-side rendering initial data
It is possible to do this using the SSR exchange, but it isn't designed well for Remix. We can work around it by using __remixContext.routeData and restoreData API.
The text was updated successfully, but these errors were encountered:
The TTFB is still terrible (although it is miles better than Prismic) and since we serve content that won't change very much, we can leverage the existing GraphQL ecosystem to cache them aggressively.
The idea
Change the GraphQL client from current poor man's implementation to
@urql/core
and cache them using Graphcache since we know a lot of data can appear from various places (usually blocks).Caching customization
Cache
ArticleRecord
by slugsWe rarely use ID value for ArticleRecord but it is without a doubt the most requested resource on the website. I propose to cache them by the pair of locale and slug which is unique enough to cache.
We can do this by leveraging the Local Resolvers feature of urql.
Instant invalidation
In combination with Dato's webhook feature, we can make Urql invalidate certain entities as soon as it gets updated. It can be done by using
cache.invalidate
.Persistent cache
We have to rely on some sort of external persistent state because Vercel's Remix hosting is essentially a Serverless Function. We could do this by Upstash's Redis hosting with custom cache options of Graphcache.
Server-side rendering initial data
It is possible to do this using the SSR exchange, but it isn't designed well for Remix. We can work around it by using
__remixContext.routeData
andrestoreData
API.The text was updated successfully, but these errors were encountered: