{"id":17372,"library":"strapi-plugin-rest-cache","title":"Strapi REST Cache Plugin","description":"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.","status":"active","version":"4.2.9","language":"javascript","source_language":"en","source_url":"https://github.com/strapi-community/strapi-plugin-rest-cache","tags":["javascript","strapi","plugin","rest","cache","http","lru"],"install":[{"cmd":"npm install strapi-plugin-rest-cache","lang":"bash","label":"npm"},{"cmd":"yarn add strapi-plugin-rest-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add strapi-plugin-rest-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Strapi application core functionality.","package":"@strapi/strapi","optional":false},{"reason":"Required for in-memory caching functionality, often installed by default.","package":"@strapi-community/provider-rest-cache-memory","optional":true},{"reason":"Required for Redis caching functionality.","package":"@strapi-community/provider-rest-cache-redis","optional":true}],"imports":[{"note":"Strapi plugins are typically enabled and configured directly in `config/plugins.js` or `src/plugins/rest-cache/admin/src/index.js` as an object within the `module.exports`, not imported as ES modules or CommonJS modules in application code directly.","wrong":"import { RestCachePlugin } from 'strapi-plugin-rest-cache';","symbol":"plugins","correct":"module.exports = { 'rest-cache': { enabled: true, config: { /* ... */ } } };"},{"note":"Configuration is handled via standard Strapi plugin configuration patterns in `config/plugins.js`. There isn't a direct TypeScript type import for the plugin's configuration object itself from the plugin's main entry point, although internal types exist.","symbol":"RestCacheConfig","correct":"// No direct import for configuration. Configuration is defined in config/plugins.js"},{"note":"Providers are separate packages and are either required directly for advanced configuration or specified by name in the plugin's configuration. They are not typically imported from the main `plugin-rest-cache` package.","wrong":"import { MemoryProvider } from '@strapi-community/plugin-rest-cache';","symbol":"RestCacheProvider","correct":"const memoryProvider = require('@strapi-community/provider-rest-cache-memory');"}],"quickstart":{"code":"module.exports = {\n  // ... other plugins\n  'rest-cache': {\n    enabled: true,\n    config: {\n      provider: {\n        name: 'memory',\n        options: {\n          max: 32767, // max number of items in cache\n          maxAge: 3600, // cache expiration time in seconds\n        },\n      },\n      strategy: {\n        contentTypes: [\n          // List of content types to cache\n          'api::article.article',\n          'api::category.category',\n        ],\n        maxAge: 3600, // global maxAge for content types\n        hitpass: false, // If true, cache will not be used if query params are present\n      },\n    },\n  },\n  // ...\n};\n","lang":"javascript","description":"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`."},"warnings":[{"fix":"Update your `package.json` to use the new scoped package names (`@strapi-community/plugin-rest-cache`, `@strapi-community/provider-rest-cache-*`) and reinstall dependencies. Adjust any internal references in configuration files.","message":"The `strapi-plugin-rest-cache` package name changed to `@strapi-community/plugin-rest-cache` in v5.0.0. Additionally, all provider packages (e.g., `strapi-provider-rest-cache-memory`) were renamed to their `@strapi-community` scoped equivalents.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"If you were using the Couchbase Provider, you must migrate to an alternative provider such as Redis or implement a custom provider. There is no direct replacement within the plugin for Couchbase.","message":"The Couchbase Provider was entirely removed in v5.0.0 due to lack of maintenance and testing resources.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Exercise caution, thoroughly test in development environments, and monitor the official GitHub repository for updates and breaking changes. Consider this for any version based on README warnings.","message":"The README explicitly states the package is currently under 'ALPHA' status, indicating potential instability, API changes without major version bumps, or incomplete features. While v5.0.0 is released, this warning from the README for prior versions implies ongoing development and refinement.","severity":"gotcha","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Ensure your Strapi project is on version 4 or higher. For Strapi v3, use `strapi-middleware-cache` instead.","message":"This plugin is specifically for Strapi v4.x.x and v5.x.x. It is not compatible with Strapi v3.x. The recommended alternative for Strapi v3.x is `strapi-middleware-cache`.","severity":"gotcha","affected_versions":"<4.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using the correct package name `@strapi-community/plugin-rest-cache` in your `package.json` and in your Strapi plugin configuration file (e.g., `config/plugins.js`).","cause":"The package name for the plugin has changed in Strapi v5.","error":"Error: Cannot find module 'strapi-plugin-rest-cache'"},{"fix":"Review your `config/plugins.js` file for the `rest-cache` entry. Ensure that `enabled: true` is set and that the `config` object correctly defines a `provider` and `strategy` with valid options, including `name` for the provider.","cause":"The plugin is enabled but misconfigured, often missing the `provider` or `strategy` objects, or having incorrect syntax.","error":"TypeError: Cannot read properties of undefined (reading 'config') at module.exports"},{"fix":"Verify that the `contentTypes` array in your plugin configuration's `strategy` includes the exact API ID of the content types you expect to be purged. E.g., `['api::article.article']`.","cause":"This typically happens if the `strategy.contentTypes` array is not correctly configured to include the relevant content types, or if the content types are not properly exposed via the REST API.","error":"Cache is not being purged automatically when content types are updated."}],"ecosystem":"npm","meta_description":null}