@ngx-ssr/cache
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@ngx-ssr/cache

Install package

npm i @ngx-ssr/cache

Import the NgxSsrCacheModule module to cache all GET requests

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxSsrCacheModule } from '@ngx-ssr/cache';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    NgxSsrCacheModule.configLruCache({ maxAge: 10 * 60_000, maxSize: 50 }),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {
}

HTML caching is also available for express

import { ngExpressEngine } from '@nguniversal/express-engine';
import { LRUCache } from '@ngx-ssr/cache';
import { withCache } from '@ngx-ssr/cache/express';

server.engine(
  'html',
  withCache(
    new LRUCache({ maxAge: 10 * 60_000, maxSize: 100 }),
    ngExpressEngine({
      bootstrap: AppServerModule,
    })
  )
);

/@ngx-ssr/cache/

    Package Sidebar

    Install

    npm i @ngx-ssr/cache

    Weekly Downloads

    308

    Version

    1.2.1

    License

    none

    Unpacked Size

    152 kB

    Total Files

    38

    Last publish

    Collaborators

    • defenderbass