File tree 2 files changed +6
-29
lines changed
2 files changed +6
-29
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,14 @@ export const setCacheControl = (
6
6
next : ( ) => void
7
7
) => {
8
8
const {
9
- query : { cache_time } ,
9
+ query : { cache_time, _vercel_no_cache } ,
10
10
} = res . locals ;
11
- const cacheValue = `s-maxage=${
12
- cache_time || 60
13
- } , stale-while-revalidate=604800`;
14
- res . setHeader ( "Cache-Control" , cacheValue ) ;
15
11
16
- if ( req . query . _vercel_no_cache && req . query . _vercel_no_cache === "1" ) {
17
- res . setHeader ( "Cache-Control" , "s-maxage=1, stale-while-revalidate=59" ) ;
12
+ res . setHeader ( "Cache-Control" , "max-age=60" ) ;
13
+ if ( _vercel_no_cache === undefined ) {
14
+ res . setHeader ( "CDN-Cache-Control" , `max-age=${ cache_time } ` ) ;
15
+ res . setHeader ( "Vercel-CDN-Cache-Control" , `max-age=${ cache_time } ` ) ;
18
16
}
17
+
19
18
next ( ) ;
20
19
} ;
Original file line number Diff line number Diff line change @@ -28,28 +28,6 @@ const nextConfig = {
28
28
} ,
29
29
] ;
30
30
} ,
31
- async headers ( ) {
32
- return [
33
- {
34
- source : "/api/view" ,
35
- headers : [
36
- {
37
- key : "Cache-Control" ,
38
- value : "s-maxage=60, stale-while-revalidate=604800" ,
39
- } ,
40
- ] ,
41
- } ,
42
- {
43
- source : "/api/view/:id*" ,
44
- headers : [
45
- {
46
- key : "Cache-Control" ,
47
- value : "s-maxage=60, stale-while-revalidate=604800" ,
48
- } ,
49
- ] ,
50
- } ,
51
- ] ;
52
- } ,
53
31
} ;
54
32
55
33
module . exports = nextConfig ;
You can’t perform that action at this time.
0 commit comments