Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-cache-ssr

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-cache-ssr

[![NPM version](https://img.shields.io/npm/v/nuxt-cache-ssr.svg)](https://www.npmjs.com/package/nuxt-cache-ssr)

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nuxt-cache-ssr

NPM version

In Memory Cache middleware for Nuxt3 SSR rendering .

Setup

npm install nuxt-cache-ssr

or

yarn add nuxt-cache-ssr

then inside your nuxt.config.js add cache config:

module.exports = {
  modules: [
      'nuxt-cache-ssr',
  ],
  cache: {
   
    pages: [
      // these are prefixes of pages that need to be cached
      '/page1',
      '/page2',

    ],
    key:(route:string,headers: any,device:Device)=>{

          // Link to the function will be broken, so cannot use any imported modules or custom functions
          //sample of using device to generate key
        
          const {userAgent,...deviceType} = device
          const key = [route];
          Object.keys(deviceType).forEach(val => {
            if(deviceType[val]){
              key.push(val)
            }
          })
           // returned value will be hashed using ohash
          return key.join("-")
    }
  },

  // ...
};

Device Interface

interface Device {
  userAgent: string
  isDesktop: boolean
  isIos: boolean
  isAndroid: boolean
  isMobile: boolean
  isMobileOrTablet: boolean
  isDesktopOrTablet: boolean
  isTablet: boolean
  isWindows: boolean
  isMacOS: boolean
  isApple: boolean
  isSafari: boolean
  isFirefox: boolean
  isEdge: boolean
  isChrome: boolean
  isSamsung: boolean
  isCrawler: boolean
}

TODO

  • In Memory cache options
  • Regex for Pages
  • Custom Key for Page Cache
  • Redis Cache

Keywords

FAQs

Package last updated on 28 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc