next-drupal-starterkit icon indicating copy to clipboard operation
next-drupal-starterkit copied to clipboard

NEX-104: Add redis for caching frontend

Open vermario opened this issue 1 year ago • 1 comments

Some more investigation for this is needed: if we add this, maybe there's no point anymore in doing the pre-generation of pages during build? Since redis is not available in circle ci?

This PR adds redis support in Lando and Silta to be used as next.js caching.

(does not involve Drupal at all).

  1. add Redis to the lando setup, adding a utility command to debug lando locally
  2. add the generation of a unique build id in next
  3. @neshca/cache-handler to tell next.js to use redis for its cache
  4. enable Redis in silta, now that the frontend chart also allows it after this was merged (https://github.com/wunderio/frontend-project-k8s/pull/117), and set autoscaling options to always have at least 2 containers to demonstrate that they can share the redis cache

To test

  1. run the ./setup.sh -c
  2. check that the site works :-)
  3. you can install Redis insight (or another redis client) and connect it to lando to see data being cached.

Screenshots

Redis insight running locally, showing data being saved and read from Redis: image

Silta dashboard showing multiple node pods running, sharing the load: image

vermario avatar Feb 22 '24 06:02 vermario

In the meantime, there have been newer versions of the cache handler, so it might worth revisiting that part: https://github.com/caching-tools/next-shared-cache/blob/canary/packages/cache-handler/CHANGELOG.md

vermario avatar May 22 '24 08:05 vermario

Relevant github issue: https://github.com/caching-tools/next-shared-cache/issues/514

vermario avatar Aug 01 '24 05:08 vermario