Skip to content

Commit d4e90bc

Browse files
committed
feat: disable caching except analytic routes
1 parent 7900148 commit d4e90bc

File tree

9 files changed

+311
-370
lines changed

9 files changed

+311
-370
lines changed

lib/actions/lost-borrow.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use server'
2-
import { revalidatePath } from 'next/cache'
2+
33
import { lostBorrow } from '../api/borrow'
44
import { Verify } from '../firebase/firebase'
55

@@ -27,11 +27,11 @@ export async function lostBorrowAction(
2727
}
2828
return { error: 'failed to mark as lost' }
2929
} finally {
30-
revalidatePath(`/admin/borrows/${data.id}`)
31-
revalidatePath(`/admin/borrows`)
32-
revalidatePath(`/borrows/${data.id}`)
33-
revalidatePath('/borrows')
34-
revalidatePath('/admin/books')
35-
revalidatePath('/books')
30+
// revalidatePath(`/admin/borrows/${data.id}`)
31+
// revalidatePath(`/admin/borrows`)
32+
// revalidatePath(`/borrows/${data.id}`)
33+
// revalidatePath('/borrows')
34+
// revalidatePath('/admin/books')
35+
// revalidatePath('/books')
3636
}
3737
}

lib/actions/return-borrow.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use server'
2-
import { revalidatePath } from 'next/cache'
2+
33
import { returnBorrow } from '../api/borrow'
44
import { Verify } from '../firebase/firebase'
55

@@ -36,11 +36,11 @@ export async function returnBorrowAction({
3636
}
3737
return { error: 'failed to return borrow' }
3838
} finally {
39-
revalidatePath(`/admin/borrows/${id}`)
40-
revalidatePath(`/admin/borrows`)
41-
revalidatePath(`/borrows/${id}`)
42-
revalidatePath('/borrows')
43-
revalidatePath('/admin/books')
44-
revalidatePath('/books')
39+
// revalidatePath(`/admin/borrows/${id}`)
40+
// revalidatePath(`/admin/borrows`)
41+
// revalidatePath(`/borrows/${id}`)
42+
// revalidatePath('/borrows')
43+
// revalidatePath('/admin/books')
44+
// revalidatePath('/books')
4545
}
4646
}

lib/actions/undo-lost.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use server'
2-
import { revalidatePath } from 'next/cache'
2+
33
import { deleteLost } from '../api/borrow'
44
import { Verify } from '../firebase/firebase'
55

@@ -28,11 +28,11 @@ export async function undoLostAction(id: string) {
2828
}
2929
return { error: 'failed to undo lost' }
3030
} finally {
31-
revalidatePath(`/admin/borrows/${id}`)
32-
revalidatePath(`/admin/borrows`)
33-
revalidatePath(`/borrows/${id}`)
34-
revalidatePath('/borrows')
35-
revalidatePath('/admin/books')
36-
revalidatePath('/books')
31+
// revalidatePath(`/admin/borrows/${id}`)
32+
// revalidatePath(`/admin/borrows`)
33+
// revalidatePath(`/borrows/${id}`)
34+
// revalidatePath('/borrows')
35+
// revalidatePath('/admin/books')
36+
// revalidatePath('/books')
3737
}
3838
}

lib/actions/undo-return.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use server'
2-
import { revalidatePath } from 'next/cache'
2+
33
import { deleteReturn } from '../api/borrow'
44
import { Verify } from '../firebase/firebase'
55

@@ -25,11 +25,11 @@ export async function undoReturnAction(id: string) {
2525
}
2626
return { error: 'failed to undo return' }
2727
} finally {
28-
revalidatePath(`/admin/borrows/${id}`)
29-
revalidatePath(`/admin/borrows`)
30-
revalidatePath(`/borrows/${id}`)
31-
revalidatePath('/borrows')
32-
revalidatePath('/admin/books')
33-
revalidatePath('/books')
28+
// revalidatePath(`/admin/borrows/${id}`)
29+
// revalidatePath(`/admin/borrows`)
30+
// revalidatePath(`/borrows/${id}`)
31+
// revalidatePath('/borrows')
32+
// revalidatePath('/admin/books')
33+
// revalidatePath('/books')
3434
}
3535
}

lib/actions/update-book.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use server'
22

3-
import { revalidatePath } from 'next/cache'
43
import { Verify } from '../firebase/firebase'
54
import { updateBook } from '../api/book'
65
import { processImageFile } from '../utils/image-processing'
@@ -57,8 +56,8 @@ export async function updateBookAction(
5756
error: res.error,
5857
}
5958
}
60-
revalidatePath('/admin/books')
61-
revalidatePath('/books')
59+
// revalidatePath('/admin/books')
60+
// revalidatePath('/books')
6261
return { message: 'Book updated successfully' }
6362
} catch (e) {
6463
console.error(e)

lib/actions/update-borrow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use server'
22

3-
import { revalidatePath } from 'next/cache'
43
import { updateBorrow } from '../api/borrow'
54
import { Verify } from '../firebase/firebase'
65

@@ -22,9 +21,9 @@ export async function updateBorrowAction(
2221
}
2322
return { error: 'failed to update borrow' }
2423
} finally {
25-
revalidatePath(`/admin/borrows/${data.id}`)
26-
revalidatePath(`/admin/borrows`)
27-
revalidatePath(`/borrows/${data.id}`)
28-
revalidatePath('/borrows')
24+
// revalidatePath(`/admin/borrows/${data.id}`)
25+
// revalidatePath(`/admin/borrows`)
26+
// revalidatePath(`/borrows/${data.id}`)
27+
// revalidatePath('/borrows')
2928
}
3029
}

lib/api/book.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ export const getListBooks = async ({
2727
url.searchParams.append('ids', ids.join(','))
2828
}
2929

30-
const response = await fetch(url.toString(), {
31-
cache: 'force-cache',
32-
next: {
33-
revalidate: 60,
34-
},
35-
})
30+
const response = await fetch(url.toString())
3631
return response.json()
3732
}
3833

@@ -48,12 +43,7 @@ export const getBook = async (query: GetBookQuery): GetBookResponse => {
4843
url.searchParams.append(key, String(value))
4944
}
5045
})
51-
const response = await fetch(url.toString(), {
52-
cache: 'force-cache',
53-
next: {
54-
revalidate: 30,
55-
},
56-
})
46+
const response = await fetch(url.toString())
5747
return response.json()
5848
}
5949

lib/api/borrow.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ export const getListBorrows = async (
4141
}
4242
}
4343

44-
const response = await fetch(url.toString(), {
45-
...init,
46-
cache: 'force-cache',
47-
next: {
48-
revalidate: 60,
49-
},
50-
})
44+
const response = await fetch(url.toString(), init)
5145
if (!response.ok) {
5246
const e = await response.json()
5347
throw e
@@ -102,13 +96,7 @@ export const getBorrow = async (
10296
url.searchParams.append('is_lost', 'true')
10397
}
10498
}
105-
const response = await fetch(url.toString(), {
106-
...init,
107-
cache: 'force-cache',
108-
next: {
109-
revalidate: 60,
110-
},
111-
})
99+
const response = await fetch(url.toString(), init)
112100
if (!response.ok) {
113101
const e = await response.json()
114102
throw e

0 commit comments

Comments
 (0)