Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urql #15

Open
BasixKOR opened this issue Feb 8, 2022 · 0 comments · May be fixed by #21
Open

Urql #15

BasixKOR opened this issue Feb 8, 2022 · 0 comments · May be fixed by #21

Comments

@BasixKOR
Copy link
Owner

BasixKOR commented Feb 8, 2022

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.

@BasixKOR BasixKOR linked a pull request Feb 9, 2022 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant