Releases: next-boost/next-boost
Metrics support and cache status header
In 0.15.x, two new features are added
- Prometheus metrics
- Cache status in HTTP header
Prometheus metrics
You can enable metrics in the config
// in .next-boost.js
{
...
metrics: true,
}
And by requesting __nextboost_metrics
, you'll get Prometheus style metrics
$ curl http://localhost:3000/__nextboost_metrics
next_boost_requests_total{status='stale'} 1
next_boost_requests_total{status='bypass'} 32
next_boost_requests_total{status='hit'} 2
Cache status in HTTP header
Also, a x-next-boost-status
header is now returned in all requests
$ curl -I http://localhost:3000/
HTTP/1.1 200 OK
x-next-boost-status: hit
x-powered-by: Next.js
etag: "f5274-diDR3qXA2Yvq7BYsnHn3HjQ3Qq8"
content-type: text/html; charset=utf-8
content-length: 262875
cache-control: private, no-cache, no-store, max-age=0, must-revalidate
date: Wed, 22 Dec 2021 01:57:00 GMT
connection: close
content-encoding: gzip
Binary encoder for better performance
Now headers and body are encoded in their own binary format before storing in the cache.
This makes it faster and safer to read/write data from the cache.
Also, exception handling has been added when data from the cache is corrupted.
Use sync lock from cache
After we've added the official support of redis-cache adapter, it's obvious that using a process-level SYNC_LOCK will not be able to sync between different instances in a cluster of next-boost.
In this release, the SYNC_LOCK is moved to the cache and thus be able to be shared between instances.
Fix unhandled exception
Add handling when we have corrupted data in the cache.
A new home & graceful shutdown
In this release, we've moved next-boost to its own organization with other related libs.
You can install the new package with npm install @next-boost/next-boost
And the following features are added:
- Graceful shutdown by SIGTERM (edfb5f3)
- Peer dependencies for Next.js upgraded to 12.x
With the following bugs fixed:
- Cache could be empty (6e31ac7)
Adding function based rules resolver
A much flexible way to control how the cache works for different requests.
Functions should return valid TTL for the request. If the function returns 0 or falsy value
the request will not be cached.
// in .next-boost.js
{
...
rules: (req) => {
if (req.url.startsWith('/blog')) {
return 300
}
}
}
Thank you @capJavert for bringing us the PR #52
Async Cache Interface
All the underlying cache interfaces are now async.
And this will make it possible to add cache adapters like Redis
and more.
export type CacheAdapter = {
set(key: string, value: Buffer, ttl?: number): Promise<void>
get(key: string, defaultValue?: Buffer): Promise<Buffer | undefined>
has(key: string): Promise<CacheStatus>
del(key: string): Promise<void>
}
Force production
Support Next.js v11
- Support Next.js v10 & v11
- Update packages
Fix cacheKey's execution order
Use filtered URL to generate the cacheKey.