diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..3c3075e --- /dev/null +++ b/.eslintrc @@ -0,0 +1,25 @@ +{ + "env": { + "commonjs": true, + "es2021": true, + "node": true + }, + "extends": ["eslint:recommended", "plugin:import/recommended", "prettier"], + "overrides": [ + { + "env": { + "node": true + }, + "files": [".eslintrc.{js,cjs}"], + "parserOptions": { + "sourceType": "script" + } + } + ], + "parserOptions": { + "ecmaVersion": "latest" + }, + "rules": { + "no-undef": "off" + } +} diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 4251929..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - env: { - commonjs: true, - es2021: true, - node: true, - }, - extends: ["eslint:recommended", "plugin:import/recommended", "prettier"], - overrides: [ - { - env: { - node: true, - }, - files: [".eslintrc.{js,cjs}"], - parserOptions: { - sourceType: "script", - }, - }, - ], - parserOptions: { - ecmaVersion: "latest", - }, - rules: { - "no-undef": "off", - }, -}; diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e60eee7..696bc8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,31 +3,23 @@ name: tests on: workflow_call: push: - branches: [main] - paths: - - ".github/**" - - "data/**" - - "packages/**" - - "playgrounds/**" - - "shared/**" + branches: + - main + - 'dev/**' pull_request: branches: [main] - paths: - - ".github/**" - - "data/**" - - "packages/**" - - "playgrounds/**" - - "shared/**" jobs: linters: runs-on: ubuntu-latest - + strategy: + matrix: + node: [20, 22] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: ${{ matrix.node }} # cache node_modules - name: Cache dependencies @@ -49,13 +41,14 @@ jobs: e2e_memory: runs-on: ubuntu-latest - needs: [linters] - + strategy: + matrix: + node: [20, 22] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: ${{ matrix.node }} # cache node_modules - name: Cache dependencies @@ -75,14 +68,17 @@ jobs: - run: yarn postinstall:memory + - run: yarn build:plugin:rest-cache + - name: Run Memory e2e tests working-directory: playgrounds/memory run: yarn test:e2e e2e_redis: runs-on: ubuntu-latest - needs: [linters] - + strategy: + matrix: + node: [20, 22] services: redis: image: bitnami/redis:latest @@ -96,7 +92,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: ${{ matrix.node }} # cache node_modules - name: Cache dependencies @@ -116,6 +112,8 @@ jobs: - run: yarn postinstall:redis + - run: yarn build:plugin:rest-cache + - name: Run Redis e2e tests working-directory: playgrounds/redis run: yarn test:e2e diff --git a/.gitignore b/.gitignore index 2cad7bb..66760d0 100644 --- a/.gitignore +++ b/.gitignore @@ -109,4 +109,11 @@ dist cache # Strapi +license.txt +exports +.strapi +dist +build .strapi-updater.json +.strapi-cloud.json +playgrounds/**/types/* \ No newline at end of file diff --git a/.nvmrc b/.nvmrc index 58656b7..67e145b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.19.1 +v20.18.0 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c2d5f34 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "endOfLine": "lf", + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "es5", + "printWidth": 100 + } diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index a44e771..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - endOfLine: 'lf', - semi: true, - singleQuote: true, - tabWidth: 2, - trailingComma: 'es5', - printWidth: 100, - }; \ No newline at end of file diff --git a/BENCHMARKS.md b/BENCHMARKS.md index 57b93ad..f325213 100644 --- a/BENCHMARKS.md +++ b/BENCHMARKS.md @@ -1,5 +1,7 @@ # Benchmarks +These benchmarks are out of date for the current version of the plugin. They are kept here for reference and might be updated in the future. + ## Context - Rest cache version: `4.2.4` @@ -15,13 +17,13 @@ $ ENABLE_CACHE=false yarn profile:memory ``` -| Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max | -| ----------- | ------- | ------- | ------- | ------- | ---------- | --------- | ------- | +| Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max | +|-------------|---------|---------|---------|---------|------------|--------|---------| | **Latency** | 2424 ms | 2555 ms | 2921 ms | 3012 ms | 2565.12 ms | 133.23 | 3401 ms | -| Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min | -| ------------- | --- | ---- | ------ | ------- | ------ | ------ | ------ | -| **Req/Sec** | 0 | 0 | 386 | 1000 | 383.34 | 382.38 | 39 | +| Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min | +|---------------|-----|------|--------|---------|--------|--------|---------| +| **Req/Sec** | 0 | 0 | 386 | 1000 | 383.34 | 382.38 | 39 | | **Bytes/Sec** | 0 B | 0 B | 453 kB | 1.17 MB | 450 kB | 449 kB | 45.7 kB | ### Cache enabled (without etag) @@ -30,12 +32,12 @@ $ ENABLE_CACHE=false yarn profile:memory $ ENABLE_ETAG=false yarn profile:memory ``` -| Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max | -| ----------- | ------ | ------ | ------ | ------ | --------- | ------- | ------ | +| Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max | +|-------------|--------|--------|--------|--------|-----------|----------|--------| | **Latency** | 113 ms | 116 ms | 166 ms | 175 ms | 120.04 ms | 12.86 ms | 275 ms | | Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min | -| ------------- | ------- | ------- | ------- | ------- | ------- | ------ | ------- | +|---------------|---------|---------|---------|---------|---------|--------|---------| | **Req/Sec** | 7451 | 7523 | 8287 | 8687 | 8293.49 | 306.35 | 6381 | | **Bytes/Sec** | 8.85 MB | 8.93 MB | 9.84 MB | 10.3 MB | 9.84 MB | 364 kB | 7.57 MB | @@ -46,10 +48,10 @@ $ yarn profile:memory ``` | Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max | -| ----------- | ------ | ------ | ------ | ------ | --------- | -------- | ------ | +|-------------|--------|--------|--------|--------|-----------|----------|--------| | **Latency** | 119 ms | 125 ms | 185 ms | 197 ms | 131.05 ms | 16.87 ms | 307 ms | -| Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min | -| ------------- | ------- | ------- | ------- | ------- | ------- | ------ | ------- | -| **Req/Sec** | 6551 | 6559 | 7651 | 8231 | 7599.39 | 472.94 | 6100 | +| Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min | +|---------------|---------|---------|--------|---------|---------|--------|--------| +| **Req/Sec** | 6551 | 6559 | 7651 | 8231 | 7599.39 | 472.94 | 6100 | | **Bytes/Sec** | 8.05 MB | 8.07 MB | 9.4 MB | 10.1 MB | 9.34 MB | 581 kB | 7.5 MB | diff --git a/LICENSE b/LICENSE index 357ee88..d331025 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ -Copyright (c) 2022 Strapi Community. +Copyright (c) 2025 Strapi Community. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index bd6095d..77505a1 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@

Speed-up HTTP requests with LRU cache.

- - NPM Version + + NPM Version - - Monthly download on NPM + + Monthly download on NPM

@@ -17,7 +17,6 @@ - [🚦 Current Status](#-current-status) - [✨ Features](#-features) -- [🤔 Motivation](#-motivation) - [🖐 Requirements](#-requirements) - [🚚 Getting Started](#-getting-started) - [Contributing](#contributing) @@ -25,7 +24,7 @@ ## 🚦 Current Status -This package is currently under development and should be consider **ALPHA** in terms of state. I/We are currently accepting contributions and/or dedicated contributors to help develop and maintain this package. +This package is currently under development and should be consider **BETA** in terms of state. I/We are currently accepting contributions and/or dedicated contributors to help develop and maintain this package. ## ✨ Features @@ -38,21 +37,20 @@ You can set a **strategy** to tell what to cache and how much time responses sho Supported Strapi Versions: -- Strapi v4.0.x (recently tested as of January 2022) -- Strapi v4.1.x (recently tested as of March 2022) -- Strapi v4.x.x (Assumed, but possibly not tested) +- Strapi v5.x.x (recently tested as of September 2025) +**If you are looking for the Strapi v4.x support, please check the [legacy package](https://www.npmjs.com/package/strapi-plugin-rest-cache).** **If you are looking for a plugin for Strapi v3.x, please check the [strapi-middleware-cache](https://github.com/patrixr/strapi-middleware-cache/).** ## 🚚 Getting Started -[Read the Docs to Learn More.](https://strapi-community.github.io/strapi-plugin-rest-cache/) +[Read the Docs to Learn More.](https://strapi-community.github.io/plugin-rest-cache/) ## Contributing I/We are actively looking for contributors, maintainers, and others to help shape this package. As this plugins sole purpose within the Strapi community is to be used by other developers and plugin maintainers to get fast responses time. -If interested please feel free to email the lead maintainer Sacha at: sacha@digisquad.io or ping `stf#3254` on Discord. +If interested please feel free to open an issue or pull request. ## License diff --git a/docs/.vitepress/components/LegacyWarning.vue b/docs/.vitepress/components/LegacyWarning.vue new file mode 100644 index 0000000..6baa89f --- /dev/null +++ b/docs/.vitepress/components/LegacyWarning.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/docs/.vitepress/components/VersionSwitcher.vue b/docs/.vitepress/components/VersionSwitcher.vue new file mode 100644 index 0000000..5875c85 --- /dev/null +++ b/docs/.vitepress/components/VersionSwitcher.vue @@ -0,0 +1,161 @@ + + + + + + + diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 1f45c30..fb4c738 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -1,15 +1,19 @@ import { createRequire } from 'module' -import { defineConfig } from 'vitepress' +import defineVersionedConfig from 'vitepress-versioning-plugin-patched' const require = createRequire(import.meta.url) -const pkg = require('strapi-plugin-rest-cache/package.json') +const pkg = require('@strapi-community/plugin-rest-cache/package.json') -export default defineConfig({ +export default defineVersionedConfig({ title: "REST Cache", description: "Speed-up HTTP requests with LRU cache", base: "/plugin-rest-cache/", lastUpdated: true, + versioning: { + latestVersion: pkg.version, + }, themeConfig: { + versionSwitcher: false, socialLinks: [ { icon: 'github', link: 'https://github.com/strapi-community/plugin-rest-cache' }, ], @@ -31,17 +35,7 @@ export default defineConfig({ activeMatch: '/guide/', }, { - text: pkg.version, - items: [ - { - text: 'Changelog', - link: 'https://github.com/strapi-community/plugin-rest-cache/blob/main/CHANGELOG.md' - }, - { - text: 'Strapi Community', - link: 'https://github.com/strapi-community' - } - ] + component: 'VersionSwitcher', } ], sidebar: { @@ -60,7 +54,6 @@ export default defineConfig({ { text: 'Provider configuration', link: '/guide/provider/' }, { text: 'Provider: Memory', link: '/guide/provider/memory' }, { text: 'Provider: Redis', link: '/guide/provider/redis' }, - { text: 'Provider: Couchbase', link: '/guide/provider/couchbase' }, { text: 'Custom provider', link: '/guide/provider/custom-provider' }, ] }, @@ -82,7 +75,46 @@ export default defineConfig({ { text: 'Services', link: '/guide/api/' }, { text: 'Admin Routes', link: '/guide/api/admin-routes' }, ] - } + }, + ], + '/4.x.x/': [ + { + text: 'Guide', + items: [ + { text: 'Introduction', link: '/4.x.x/' }, + { text: 'Installation', link: '/4.x.x/installation' }, + ] + }, + { + text: 'Provider', + collapsible: true, + items: [ + { text: 'Provider configuration', link: '/4.x.x/provider/' }, + { text: 'Provider: Memory', link: '/4.x.x/provider/memory' }, + { text: 'Provider: Redis', link: '/4.x.x/provider/redis' }, + { text: 'Provider: Couchbase', link: '/4.x.x/provider/couchbase' }, + { text: 'Custom provider', link: '/4.x.x/provider/custom-provider' }, + ] + }, + { + text: 'Strategy', + collapsible: true, + items: [ + { text: 'Strategy configuration', link: '/4.x.x/strategy/' }, + { text: 'Cache content type', link: '/4.x.x/strategy/cache-content-type' }, + { text: 'Cache custom routes', link: '/4.x.x/strategy/cache-custom-routes' }, + { text: 'Cache keys', link: '/4.x.x/strategy/cache-keys' }, + { text: 'Debug mode', link: '/4.x.x/strategy/debug' }, + ] + }, + { + text: 'API', + collapsible: true, + items: [ + { text: 'Services', link: '/4.x.x/api/' }, + { text: 'Admin Routes', link: '/4.x.x/api/admin-routes' }, + ] + }, ], '/reference/': [ { @@ -97,4 +129,4 @@ export default defineConfig({ ] } } -}) +}, __dirname); diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/Layout.vue index 43f4b6a..872d048 100644 --- a/docs/.vitepress/theme/Layout.vue +++ b/docs/.vitepress/theme/Layout.vue @@ -1,37 +1,17 @@