1.110.2 • Published 2 years ago

@tramvai/module-server-response-cache v1.110.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Server response cache

Caches the responses from the server for the requests in order to respond quickly

Installation

You need to install @tramvai/module-server-response-cache

npm i --save @tramvai/module-server-response-cache

And connect to the project

import { createApp } from '@tramvai/core';
import { ServerResponseCacheModule } from '@tramvai/module-server-response-cache';

createApp({
  name: 'tincoin',
  modules: [ServerResponseCacheModule],
});

Explanation

Module mostly focused on providing high RPS for the server by disabling part of the functionality on ssr and caching non-personalized requests.

:::warning

This type of caching implies no personalization for the individual requests. That means a lot of requests will be served as anonymous pages without most of the ssr preparations for the client. Be sure your app can successfully dehydrate on the client in this case and can load any additional data required to the end user in browser.

:::

Getting from cache

Conditions when value is returned from cache:

Running full ssr to fill cache

  • In case there is no value cache
  • In case there is value in cache, but its ttl is outdated. In this case the cached value will still be send to client, but it will be updated in the background.

Setting to cache

Options

  • ttl - time to live of the cache entry. 1 minute by default.
  • maxSize - max number of entries in cache. 50 entries by default
  • line - specify the commandLine to execute checking cache. Might be used in case you need some additional data from di that is filled on next lines. By default cache check is executed on customerStart

How to

Exported tokens

RESPONSE_CACHE_SHOULD_USE_CACHE

Function that returns flag that current request should be handled by cache.

Default: always true.

RESPONSE_CACHE_GET_CACHE_KEY

Function that return string that is used as cache key.

Default: request pathname + deviceType (mobile or desktop)

RESPONSE_CACHE_SHOULD_SET_TO_CACHE

Function that return flag that current response should be cache. As some requests may contain personal info for the client not every response can be cache.

Default: true if there is no cookies for the request

RESPONSE_CACHE_OPTIONS

Specify response cache options

2.32.0

2 years ago

2.31.0

2 years ago

2.29.0

2 years ago

2.27.0

2 years ago

2.25.1

2 years ago

2.20.0

2 years ago

2.22.0

2 years ago

2.20.1

2 years ago

2.28.0

2 years ago

2.26.2

2 years ago

2.24.1

2 years ago

2.24.0

2 years ago

2.24.3

2 years ago

2.26.0

2 years ago

2.21.0

2 years ago

2.21.1

2 years ago

2.11.0

2 years ago

2.0.2

2 years ago

2.2.3

2 years ago

2.4.0

2 years ago

2.2.2

2 years ago

2.0.7

2 years ago

2.6.2

2 years ago

1.109.0

2 years ago

2.0.0

2 years ago

2.3.0

2 years ago

2.10.2

2 years ago

2.5.0

2 years ago

2.7.0

2 years ago

2.7.1

2 years ago

1.108.1

2 years ago

1.110.2

2 years ago

1.110.0

2 years ago

1.94.5

2 years ago

1.98.0

2 years ago

1.96.0

2 years ago

1.94.2

2 years ago

1.94.1

2 years ago

1.94.0

2 years ago

1.105.3

2 years ago

1.101.8

2 years ago

1.105.2

2 years ago

1.101.6

2 years ago

1.101.3

2 years ago

1.101.4

2 years ago

1.103.0

2 years ago

1.101.2

2 years ago

1.99.1

2 years ago

1.97.0

2 years ago

1.95.2

2 years ago

1.95.1

2 years ago

1.95.0

2 years ago

1.106.0

2 years ago

1.104.2

2 years ago

1.102.1

2 years ago

1.101.9

2 years ago

1.105.6

2 years ago

1.90.6

2 years ago

1.92.3

2 years ago

1.93.1

2 years ago

1.92.2

2 years ago

1.90.4

2 years ago

1.92.0

2 years ago

1.91.1

2 years ago

1.90.2

2 years ago

1.91.0

2 years ago

1.90.1

2 years ago

1.84.0

2 years ago

1.85.0

2 years ago

1.84.2

2 years ago

1.89.1

2 years ago

1.82.1

2 years ago

1.82.2

2 years ago

1.82.3

2 years ago

1.81.0

2 years ago

1.79.0

2 years ago

1.78.3

2 years ago

1.78.2

2 years ago

1.78.1

2 years ago

1.78.0

2 years ago