@rezo-zero/nuxt-cache-control 0.0.3 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -37,6 +37,25 @@ export default defineNuxtConfig({
|
|
|
37
37
|
|
|
38
38
|
That's it! You can now use Nuxt Cache Control in your Nuxt app with `useCacheControl` composable.
|
|
39
39
|
|
|
40
|
+
```vue
|
|
41
|
+
<script setup>
|
|
42
|
+
/*
|
|
43
|
+
* Define SSR cache control header for this page
|
|
44
|
+
*/
|
|
45
|
+
useCacheControl({
|
|
46
|
+
public: true,
|
|
47
|
+
// 1 hour
|
|
48
|
+
maxAge: 60 * 60,
|
|
49
|
+
// 30 minutes
|
|
50
|
+
sMaxAge: 60 * 30,
|
|
51
|
+
// SWR for 2 minutes
|
|
52
|
+
staleWhileRevalidate: 60 * 2,
|
|
53
|
+
})
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Cache control composable accepts the following options:
|
|
58
|
+
|
|
40
59
|
```ts
|
|
41
60
|
export interface CacheControlOptions {
|
|
42
61
|
maxAge?: number // in seconds
|
package/dist/module.json
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { getResponseStatus, setResponseHeader, getQuery, parseCookies } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
|
+
function defineNitroPlugin(def) {
|
|
4
|
+
return def;
|
|
5
|
+
}
|
|
1
6
|
export default defineNitroPlugin((nitroApp) => {
|
|
2
7
|
nitroApp.hooks.hook("render:response", (_response, { event }) => {
|
|
3
8
|
const qs = getQuery(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rezo-zero/nuxt-cache-control",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Declare fine-grained cache control headers for your Nuxt application in each page",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@nuxt/kit": "^3.11.1",
|
|
35
|
-
"defu": "^6.1.4"
|
|
35
|
+
"defu": "^6.1.4",
|
|
36
|
+
"nitropack": "^2.9.5"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@nuxt/devtools": "latest",
|
|
@@ -52,4 +53,4 @@
|
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": "^20"
|
|
54
55
|
}
|
|
55
|
-
}
|
|
56
|
+
}
|