{"id":46533,"library":"strapi-middleware-cache","title":"Strapi Middleware Cache","description":"A cache middleware for Strapi v3 headless CMS that caches incoming GET requests and auto-busts on write operations. Current stable version is 2.1.8 (deprecated). Last updated 2021, no longer maintained. Requires Strapi 3.4.0+ and Node 14. Supports memory and Redis storage engines with per-model caching configuration. Deprecated in favor of strapi-plugin-rest-cache for Strapi v4. Key differentiator: simple LRU caching with automatic cache invalidation on PUT/PATCH/POST/DELETE.","status":"deprecated","version":"2.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/patrixr/strapi-middleware-cache","tags":["javascript","cache","strapi","requests","redis","memcache","typescript"],"install":[{"cmd":"npm install strapi-middleware-cache","lang":"bash","label":"npm"},{"cmd":"yarn add strapi-middleware-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add strapi-middleware-cache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Config must be a function receiving env in Strapi v3.","wrong":"module.exports = { settings: { cache: { enabled: true } } };","symbol":"cache middleware","correct":"module.exports = ({ env }) => ({ settings: { cache: { enabled: true } } });"},{"note":"Model names must be lowercase, matching Strapi content type UIDs.","wrong":"models: ['Article', 'Product']","symbol":"Model config","correct":"models: ['article', 'product']"},{"note":"Redis config uses 'hosts' array, not single host/port.","wrong":"model: { type: 'redis', host: '127.0.0.1', port: 6379 }","symbol":"Redis storage","correct":"model: { type: 'redis', redis: { hosts: ['127.0.0.1:6379'] } }"}],"quickstart":{"code":"// config/middleware.js\nmodule.exports = ({ env }) => ({\n  settings: {\n    cache: {\n      enabled: true,\n      models: ['review'],\n      type: 'redis',\n      redis: {\n        hosts: [\n          { host: '127.0.0.1', port: 6379 }\n        ]\n      }\n    }\n  }\n});","lang":"javascript","description":"Enable cache for 'review' model with Redis storage backend."},"warnings":[{"fix":"Use https://github.com/strapi-community/strapi-plugin-rest-cache","message":"Project is deprecated; switch to strapi-plugin-rest-cache.","severity":"deprecated","affected_versions":"<=2.1.8"},{"fix":"Re-read documentation and update config for v2 format.","message":"Full rewrite from v1 to v2; config may not be compatible.","severity":"breaking","affected_versions":">=2.0.0 <2.0.1"},{"fix":"Use e.g., 'article' not 'Article'.","message":"Model names must be lowercase strings matching Strapi content type UIDs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use hosts: [{ host: '...', port: 6379 }]","message":"Redis hosts config requires array of objects with host and port.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'14':41 '2.1.8':28 '2021':32 '3.4.0':38 'auto':19 'auto-bust':18 'automat':72 'bust':20 'cach':3,5,13,52,62,70,73,78 'cms':11 'configur':53 'current':24 'deprec':29,54 'differenti':67 'engin':47 'favor':56 'get':15 'headless':10 'incom':14 'invalid':74 'javascript':77 'key':66 'last':30 'longer':34 'lru':69 'maintain':35 'memcach':82 'memori':43 'middlewar':2,6 'model':51 'node':40 'oper':23 'per':50 'per-model':49 'plugin':60 'put/patch/post/delete':76 'redi':45,81 'request':16,80 'requir':36 'rest':61 'simpl':68 'stabl':25 'storag':46 'strapi':1,8,37,59,64,79 'strapi-plugin-rest-cach':58 'support':42 'typescript':83 'updat':31 'v3':9 'v4':65 'version':26 'write':22","created_at":"2026-06-07T13:00:23.987424+00:00","updated_at":"2026-06-07T13:00:23.987424+00:00","problems":[{"fix":"Ensure config/middleware.js exports function with settings.cache.","cause":"Middleware config not wrapped in settings key or missing file.","error":"TypeError: Cannot read property 'cache' of undefined"},{"fix":"Use lowercase model UID in models array, e.g., 'article'.","cause":"Model name case mismatch or not in models array.","error":"Error: No cache configuration found for model 'Article'"},{"fix":"Use hosts: [{ host: '127.0.0.1', port: 6379 }]","cause":"Redis config uses single host/port instead of hosts array.","error":"Error: Redis configuration is invalid - hosts must be an array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/patrixr/strapi-middleware-cache#readme","github":"https://github.com/patrixr/strapi-middleware-cache","docs":null,"changelog":null,"pypi":null,"npm":"strapi-middleware-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}