Commit Graph

4 Commits

Author SHA1 Message Date
Joseph 26b2bbe024 example: Use a Redis cacheHandler w/o dependencies (#95346)
Verify locally:

- Copy the example to a local directory
- Install deps
- docker compose up -d
- npm run build && npm run start 
- navigate to localhost:3000/cet (or gmt)
- open the Redis view (link in localhost:3000/cet)
- revalidate data on /cet or /gmt
- verify it on the Redis view

I had to update the app to async params, updateTag, and write the
handler in such a way that it solved:

```
⨯ TypeError: p.segmentData.get is not a function
    at ignore-listed frames
⨯ Error: failed to pipe response
```

Also adding docs edits with this caveat.

An agent review, and cross checking with a community implementation,
surfaced, that we had to read tags from
`data.headers['x-next-cache-tags']`. This agent review added a few
comments, I think they are useful, but can cut down if needed.

Last but not least, had to update the Time API endpoint (former no
longer worked).
2026-09-09 14:42:25 +02:00
Mauro Accornero 0d3a353dfb fix[examples]: update example cache-handler-redis (#67350)
### What?

Fix cache-handler-redis example with working cache handler 

### Why?

It was not working because next-shared-cache was updated but some code
inside the cache-handler.js was deprecated after version 1.0.0.

When starting the app without Redis the cache handler was not switching
to the LRU handler.

### How?

- Updated cache-handler-redis example with working cache handler from
[next-shared-cache's
example](https://caching-tools.github.io/next-shared-cache/redis)
- Add check for PHASE_PRODUCTION_BUILD to avoid [issues while building
](https://github.com/caching-tools/next-shared-cache/issues/284#issuecomment-1919145094)
- Add throw error for Redis error to switch to the LRU handler
- Updated dependencies
- Updated readme broken links
- Remove "version" from docker-compose's file because it's outdated
[version outdated](https://github.com/docker/compose/issues/11628)

Closes NEXT-66812
Fixes #66812

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2024-07-18 13:57:54 +01:00
Steven 4466ba436b chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00
Arseny e2f3059b48 Add a self-hosted shared cache example (#58000)
### What?

This pull request integrates the exemplary setup for a self-hosted Next.js application utilizing Redis as a shared cache storage. The solution supports caching at both the App and Pages routers in default and standalone modes, as well as partial pre-rendering, facilitated by the [`@neshca/cache-handler`](https://github.com/caching-tools/next-shared-cache/tree/canary/packages/cache-handler) package. The package enables customizing cache handlers and replacing the default cache provided by Next.js seamlessly.

### Why?

The motivation behind this pull request is to provide an example demonstrating how Redis can be used as a shared cache in a self-hosted environment, thereby improving the scalability of hosting multiple instances of a Next.js application.
2023-11-09 14:29:11 +00:00