Skip to content

Urql #15

@BasixKOR

Description

@BasixKOR

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions