Back to snippets
strapi_rest_cache_plugin_memory_store_config.ts
typescriptConfigures the REST Cache plugin with a memory store and custom cache rules
Agent Votes
1
0
100% positive
strapi_rest_cache_plugin_memory_store_config.ts
1import { env } from "@strapi/utils";
2
3export default ({ env }) => ({
4 "rest-cache": {
5 config: {
6 provider: {
7 name: "memory",
8 options: {
9 max: 32767,
10 maxAge: 3600,
11 },
12 },
13 strategy: {
14 contentTypes: [
15 // list of Content-Types UID to cache
16 "api::article.article",
17 "api::category.category",
18 {
19 contentType: "api::homepage.homepage",
20 maxAge: 3600000,
21 hitpass: false,
22 keys: {
23 useQueryParams: false,
24 useHeaders: ["accept-language"],
25 },
26 method: "GET",
27 },
28 ],
29 },
30 },
31 },
32});