-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Segment Cache] Support output: "export" mode
Adds support for output: "export" mode to the Segment Cache implementation. The main change is that we now output an additional `.txt` data per segment per page. When the client issues a per-segment request, it appends the segment path to the end of the page URL, rather than passing it as a request header. As a follow up, I need to investigate how redirects and rewrites should work in this mode.
- Loading branch information
Showing
9 changed files
with
285 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { LinkAccordion } from '../components/link-accordion' | ||
|
||
export default function OutputExport() { | ||
return ( | ||
<> | ||
<p> | ||
Demonstrates that per-segment prefetching works in{' '} | ||
<code>output: export</code> mode. | ||
</p> | ||
<ul> | ||
<li> | ||
<LinkAccordion href="/target-page">Target</LinkAccordion> | ||
</li> | ||
</ul> | ||
</> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/segment-cache/export/app/target-page/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Target() { | ||
return <div id="target-page">Target page</div> | ||
} |
23 changes: 23 additions & 0 deletions
23
test/e2e/app-dir/segment-cache/export/components/link-accordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client' | ||
|
||
import Link from 'next/link' | ||
import { useState } from 'react' | ||
|
||
export function LinkAccordion({ href, children }) { | ||
const [isVisible, setIsVisible] = useState(false) | ||
return ( | ||
<> | ||
<input | ||
type="checkbox" | ||
checked={isVisible} | ||
onChange={() => setIsVisible(!isVisible)} | ||
data-link-accordion={href} | ||
/> | ||
{isVisible ? ( | ||
<Link href={href}>{children}</Link> | ||
) : ( | ||
`${children} (link is hidden)` | ||
)} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
output: 'export', | ||
experimental: { | ||
dynamicIO: true, | ||
clientSegmentCache: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.