Next.js 9.5: Stable ISR, basePath, rewrites, and persistent caching
Key Points
- Stable Incremental Static Regeneration
- Custom basePath and routing controls
- Content-hashed page bundles for long-term caching
Summary
Next.js 9.5 (2020-07-27) adds several production-ready features that improve routing, caching, and developer experience. Highlights include Stable Incremental Static Regeneration (ISR) to update static pages in the background, a configurable basePath for serving Next.js from subpaths, first-class rewrites, redirects, and headers in next.config.js, optional trailing-slash behavior, content-hashed page bundles for long-term caching, Fast Refresh reliability improvements, a production React profiling flag, optional catch-all routes, and a beta opt-in for Webpack 5.
These changes are practical for teams migrating existing sites, optimizing cache behavior across deploys, or adopting incremental static generation at scale.
Key Points
- Incremental Static Regeneration (stable): add
revalidateingetStaticPropsto re-render pages in the background (e.g.return { props, revalidate: 1 }). Pages remain served from static cache while the new version is generated. - basePath: host Next.js on a subpath by adding
basePath: '/docs'tonext.config.js.next/linkand router APIs will automatically include the prefix. - Rewrites / Redirects / Headers: configure routing and HTTP headers in
next.config.jsvia asyncrewrites(),redirects(), andheaders()functions to proxy, redirect, or attach headers to static and server-rendered routes. - Trailing slash option: control trailing-slash behavior with
trailingSlash: trueorfalseinnext.config.jsto avoid needless redirects and match legacy URL conventions. - Persistent caching: page bundles now use deterministic content hashes instead of a global build ID, enabling long-term caching (
Cache-Control: public, max-age=31536000, immutable) for unchanged pages across deploys. - Fast Refresh improvements: clearer, more focused error messages and more reliable live-editing during development.
- Other: production React profiling flag for measuring render cost, optional catch-all routes for SEO-driven patterns, and an opt-in Webpack 5 beta for smaller/faster builds.
Practical upgrade notes
- Audit custom servers or existing rewrites/redirects when upgrading to rely on
next.config.jsoptions. - Expect improved cache hit rates after deploys due to content-hash bundles; verify CDN/edge caching settings if you had custom cache invalidation logic.
- Try ISR on a subset of pages using
revalidateto validate behavior under your backend load patterns; consider webhooks or upcoming RFCs for multi-page invalidation.