Skip to content

Commit

Permalink
revert, just adds a docs change
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed May 6, 2024
1 parent 038c00f commit 3b43d6d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ revalidatePath(path: string, type?: 'page' | 'layout'): void;
```

- `path`: Either a string representing the filesystem path associated with the data you want to revalidate (for example, `/product/[slug]/page`), or the literal route segment (for example, `/product/123`). Must be less than 1024 characters. This value is case-sensitive.
- `type`: (optional) `'page'` or `'layout'` string to change the type of path to revalidate. If `path` contains a dynamic segment (for example, `/product/[slug]/page`), this parameter is required.
- `type`: (optional) `'page'` or `'layout'` string to change the type of path to revalidate. If `path` contains a dynamic segment (for example, `/product/[slug]/page`), this parameter is required. If path refers to the literal route segment, e.g., `/product/1` for a dynamic page (e.g., `/product/[slug]/page`), you should not provide `type`.

## Returns

Expand Down
18 changes: 4 additions & 14 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import * as Log from '../../build/output/log'
import { trackDynamicFetch } from '../app-render/dynamic-rendering'
import type { FetchMetric } from '../base-http'
import { addPathSuffix } from '../../shared/lib/router/utils/add-path-suffix'

const isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'

Expand Down Expand Up @@ -150,21 +149,12 @@ export function addImplicitTags(staticGenerationStore: StaticGenerationStore) {

if (urlPathname) {
const parsedPathname = new URL(urlPathname, 'http://n').pathname
const derivedTags = [
// for the canonical browser URL, we still want to add derived tags so that it's possible
// to call `revalidatePath("/some/dynamic/path", "page")` and have it revalidate the page
...getDerivedTags(addPathSuffix(parsedPathname, '/page')),
// we also add the pathname itself for when "page" / "layout" aren't provided
parsedPathname,
]

for (let tag of derivedTags) {
tag = `${NEXT_CACHE_IMPLICIT_TAG_ID}${tag}`
if (!staticGenerationStore.tags?.includes(tag)) {
staticGenerationStore.tags.push(tag)
}
newTags.push(tag)
const tag = `${NEXT_CACHE_IMPLICIT_TAG_ID}${parsedPathname}`
if (!staticGenerationStore.tags?.includes(tag)) {
staticGenerationStore.tags.push(tag)
}
newTags.push(tag)
}
return newTags
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ describe('app-dir static/dynamic handling', () => {
],
"initialHeaders": {
"content-type": "application/json",
"x-next-cache-tags": "_N_T_/layout,_N_T_/api/layout,_N_T_/api/large-data/layout,_N_T_/api/large-data/route,_N_T_/api/large-data/page,_N_T_/api/large-data",
"x-next-cache-tags": "_N_T_/layout,_N_T_/api/layout,_N_T_/api/large-data/layout,_N_T_/api/large-data/route,_N_T_/api/large-data",
},
"initialRevalidateSeconds": false,
"srcRoute": "/api/large-data",
Expand Down Expand Up @@ -1455,7 +1455,7 @@ describe('app-dir static/dynamic handling', () => {
],
"initialHeaders": {
"content-type": "application/json",
"x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/no-store-force-static/layout,_N_T_/route-handler/no-store-force-static/route,_N_T_/route-handler/no-store-force-static/page,_N_T_/route-handler/no-store-force-static",
"x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/no-store-force-static/layout,_N_T_/route-handler/no-store-force-static/route,_N_T_/route-handler/no-store-force-static",
},
"initialRevalidateSeconds": 3,
"srcRoute": "/route-handler/no-store-force-static",
Expand All @@ -1475,7 +1475,7 @@ describe('app-dir static/dynamic handling', () => {
],
"initialHeaders": {
"content-type": "application/json",
"x-next-cache-tags": "thankyounext,_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/revalidate-360-isr/layout,_N_T_/route-handler/revalidate-360-isr/route,_N_T_/route-handler/revalidate-360-isr/page,_N_T_/route-handler/revalidate-360-isr",
"x-next-cache-tags": "thankyounext,_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/revalidate-360-isr/layout,_N_T_/route-handler/revalidate-360-isr/route,_N_T_/route-handler/revalidate-360-isr",
},
"initialRevalidateSeconds": 10,
"srcRoute": "/route-handler/revalidate-360-isr",
Expand All @@ -1495,7 +1495,7 @@ describe('app-dir static/dynamic handling', () => {
],
"initialHeaders": {
"set-cookie": "theme=light; Path=/,my_company=ACME; Path=/",
"x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/static-cookies/layout,_N_T_/route-handler/static-cookies/route,_N_T_/route-handler/static-cookies/page,_N_T_/route-handler/static-cookies",
"x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/static-cookies/layout,_N_T_/route-handler/static-cookies/route,_N_T_/route-handler/static-cookies",
},
"initialRevalidateSeconds": false,
"srcRoute": "/route-handler/static-cookies",
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions test/e2e/app-dir/revalidate-fetch-dynamic/app/layout.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions test/e2e/app-dir/revalidate-fetch-dynamic/app/page.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions test/e2e/app-dir/revalidate-fetch-dynamic/next.config.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ describe('required server files app router', () => {
for (const [path, tags] of [
[
'/isr/first',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/first/layout,_N_T_/isr/first/page,_N_T_/isr/first',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/first',
],
[
'/isr/second',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/second/layout,_N_T_/isr/second/page,_N_T_/isr/second',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/second',
],
[
'/api/isr/first',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/first/layout,_N_T_/api/isr/first/page,_N_T_/api/isr/first',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/first',
],
[
'/api/isr/second',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/second/layout,_N_T_/api/isr/second/page,_N_T_/api/isr/second',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/second',
],
]) {
require('console').error('checking', { path, tags })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ describe('required server files app router', () => {
for (const [path, tags] of [
[
'/isr/first',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/first/layout,_N_T_/isr/first/page,_N_T_/isr/first',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/first',
],
[
'/isr/second',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/second/layout,_N_T_/isr/second/page,_N_T_/isr/second',
'isr-page,_N_T_/layout,_N_T_/isr/layout,_N_T_/isr/[slug]/layout,_N_T_/isr/[slug]/page,_N_T_/isr/second',
],
[
'/api/isr/first',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/first/layout,_N_T_/api/isr/first/page,_N_T_/api/isr/first',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/first',
],
[
'/api/isr/second',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/second/layout,_N_T_/api/isr/second/page,_N_T_/api/isr/second',
'isr-page,_N_T_/layout,_N_T_/api/layout,_N_T_/api/isr/layout,_N_T_/api/isr/[slug]/layout,_N_T_/api/isr/[slug]/route,_N_T_/api/isr/second',
],
]) {
require('console').error('checking', { path, tags })
Expand Down

0 comments on commit 3b43d6d

Please sign in to comment.