Skip to main content

Caching

Multiple levels of caching will be utilised. We will build the demo store framework with minimal caching implemented. After a review, we will implement various caching methods where appropriate.

Layers

Third-party platforms

SERVER-SIDE

Most third-party platforms implement their own caching layer. A Magento caching layer will be implemented by the Overdose Magento development team.

Data sources

SERVER-SIDE

Our API data sources will be instances of the apollo-datasource-http data source class. apollo-datasource-http supports HTTP request caching and deduplication. Additional data source caching can be implemented with Memcached or Redis with the appropriate Apollo Server plugin.

See Data Sources for more info.

Apollo Server

SERVER-SIDE

Apollo supports response caching using apollo-server-plugin-response-cache. Individual query responses can be cached in memory, or in a Memcached or Redis cache.

Responses can be cached on a per-customer level.

Nextjs static pages

SERVER-SIDE

Where possible, pages will be configured to render server-side and cache using Nextjs’ ISR feature.

See Pages for more info.

Vercel

SERVER-SIDE

Vercel caches content on its edge network by default. Since we are using Nextjs it is expected that we won't need to configure any HTTP caching settings.

Service worker

FRONTEND

A service worker is implemented using next-pwa. The service worker will fulfill HTTP requests while offline.

Apollo Client

FRONTEND

Apollo Client provides an in-memory cache out of the box. Requests can be resolved locally if the necessary data already exists in the cache from a previous request.

While offline, queries can be resolved from the cache using apollo-cache-persist, which persists the Apollo cache in local-storage or session-storage. Mutations can be queued and retried using apollo-link-offline plugin.