├── package.json
├── index.js
├── README.md
└── CHANGELOG.md
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@nuxtjs/component-cache",
3 | "version": "1.1.6",
4 | "license": "MIT",
5 | "main": "index.js",
6 | "repository": "https://github.com/nuxt/modules",
7 | "homepage": "https://github.com/nuxt-community/component-cache-module",
8 | "publishConfig": {
9 | "access": "public"
10 | },
11 | "dependencies": {
12 | "lru-cache": "^6.0.0"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const LRU = require('lru-cache')
2 |
3 | module.exports = function nuxtComponentCache (options) {
4 | if (this.options.render.ssr === false) {
5 | // SSR Disabled
6 | return
7 | }
8 |
9 | // Create empty bundleRenderer object if not defined
10 | if (typeof this.options.render.bundleRenderer !== 'object' || this.options.render.bundleRenderer === null) {
11 | this.options.render.bundleRenderer = {}
12 | }
13 |
14 | // Disable if cache explicitly provided in project
15 | if (this.options.render.bundleRenderer.cache) {
16 | return
17 | }
18 |
19 | this.options.render.bundleRenderer.cache = new LRU(Object.assign({
20 | max: 10000,
21 | maxAge: 1000 * 60 * 15
22 | }, options))
23 | }
24 |
25 | module.exports.meta = require('./package.json')
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Component Cache
2 | [](https://www.npmjs.com/package/@nuxtjs/component-cache)
3 | [](https://www.npmjs.com/package/@nuxtjs/component-cache)
4 |
5 | > vue-server-renderer has built-in support for [component-level caching](http://ssr.vuejs.org/en/caching.html#component-level-caching).
6 | > This module automatically adds a LRU cache to project.
7 |
8 | ## Setup
9 | - Add `@nuxtjs/component-cache` dependency using yarn or npm to your project
10 | - Add `@nuxtjs/component-cache` to `modules` section of `nuxt.config.js`
11 | ```js
12 | {
13 | modules: [
14 | // Simple usage
15 | '@nuxtjs/component-cache',
16 |
17 | // With options
18 | ['@nuxtjs/component-cache', { maxAge: 1000 * 60 * 60 }],
19 | ]
20 | }
21 | ```
22 |
23 | ## Options
24 | See [component-level caching](https://v2.ssr.vuejs.org/guide/caching.html#component-level-caching) for mor information.
25 |
26 | ### `max`
27 | - default: `10000`
28 |
29 | ### `maxAge`
30 | - default: `1000 * 60 * 15` (15 minutes)
31 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [1.1.6](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.5...@nuxtjs/component-cache@1.1.6) (2020-07-14)
7 |
8 | **Note:** Version bump only for package @nuxtjs/component-cache
9 |
10 |
11 |
12 |
13 |
14 | ## [1.1.5](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.4...@nuxtjs/component-cache@1.1.5) (2019-05-28)
15 |
16 |
17 | ### Bug Fixes
18 |
19 | * correct homepage URLs ([#282](https://github.com/nuxt/modules/issues/282)) ([960f933](https://github.com/nuxt/modules/commit/960f933))
20 |
21 |
22 |
23 |
24 |
25 |
26 | ## [1.1.4](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.3...@nuxtjs/component-cache@1.1.4) (2018-12-19)
27 |
28 | **Note:** Version bump only for package @nuxtjs/component-cache
29 |
30 |
31 |
32 |
33 |
34 |
35 | ## [1.1.3](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.2...@nuxtjs/component-cache@1.1.3) (2018-10-01)
36 |
37 | **Note:** Version bump only for package @nuxtjs/component-cache
38 |
39 |
40 |
41 |
42 |
43 |
44 | ## [1.1.2](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.1...@nuxtjs/component-cache@1.1.2) (2018-04-27)
45 |
46 |
47 |
48 |
49 | **Note:** Version bump only for package @nuxtjs/component-cache
50 |
51 |
52 | ## [1.1.1](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.1.0...@nuxtjs/component-cache@1.1.1) (2017-11-20)
53 |
54 |
55 |
56 |
57 | **Note:** Version bump only for package @nuxtjs/component-cache
58 |
59 |
60 | # [1.1.0](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@1.0.0...@nuxtjs/component-cache@1.1.0) (2017-08-17)
61 |
62 |
63 | ### Features
64 |
65 | * **component-cache:** update for 1.0 compatibility ([447b4cc](https://github.com/nuxt/modules/commit/447b4cc))
66 |
67 |
68 |
69 |
70 |
71 | ## [0.1.4](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@0.1.3...@nuxtjs/component-cache@0.1.4) (2017-06-06)
72 |
73 |
74 |
75 |
76 |
77 | ## [0.1.3](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@0.1.2...@nuxtjs/component-cache@0.1.3) (2017-06-02)
78 |
79 |
80 |
81 |
82 |
83 | ## [0.1.2](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@0.1.1...@nuxtjs/component-cache@0.1.2) (2017-06-02)
84 |
85 |
86 | ### Bug Fixes
87 |
88 | * **component-cache:** null ssr ([528ec4c](https://github.com/nuxt/modules/commit/528ec4c))
89 |
90 |
91 |
92 |
93 |
94 | ## [0.1.1](https://github.com/nuxt/modules/compare/@nuxtjs/component-cache@0.1.0...@nuxtjs/component-cache@0.1.1) (2017-06-02)
95 |
96 |
97 | ### Bug Fixes
98 |
99 | * **component-cache:** build.ssr ([6bb414b](https://github.com/nuxt/modules/commit/6bb414b))
100 |
101 |
102 |
103 |
104 |
105 | # 0.1.0 (2017-06-02)
106 |
107 |
108 | ### Features
109 |
110 | * component-cache module ([177f0bc](https://github.com/nuxt/modules/commit/177f0bc))
111 |
--------------------------------------------------------------------------------