Strapi REST Cache Plugin

4.2.9 · active · verified Wed Apr 22

The Strapi REST Cache Plugin is a community-maintained solution for accelerating HTTP requests within Strapi applications by implementing a caching layer. It utilizes a provider-based architecture, allowing developers to choose from various storage backends like in-memory, Redis, or file system for caching responses. The plugin supports configurable caching strategies and features automatic invalidation of cached data when related content types are updated, mitigating issues with stale data. While the provided metadata indicates version 4.2.9, the latest significant release is v5.0.0, which introduced breaking changes for Strapi v5 compatibility. The project maintains an active development cadence, with frequent updates addressing bugs and adding features, aiming to improve Strapi API performance. It differentiates itself by its flexible provider system and automatic cache invalidation tied to Strapi content updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to enable the `rest-cache` plugin in a Strapi v4/v5 application using an in-memory provider and configure basic caching for specific content types in `config/plugins.js`.

module.exports = {
  // ... other plugins
  'rest-cache': {
    enabled: true,
    config: {
      provider: {
        name: 'memory',
        options: {
          max: 32767, // max number of items in cache
          maxAge: 3600, // cache expiration time in seconds
        },
      },
      strategy: {
        contentTypes: [
          // List of content types to cache
          'api::article.article',
          'api::category.category',
        ],
        maxAge: 3600, // global maxAge for content types
        hitpass: false, // If true, cache will not be used if query params are present
      },
    },
  },
  // ...
};

view raw JSON →