1
1
import type { RouteLayoutParams } from '@/app/utils' ;
2
2
import { getAssetURL } from '@/lib/assets' ;
3
+ import { buildVersion } from '@/lib/build' ;
3
4
import { getEmbeddableStaticContext } from '@/lib/embeddable' ;
4
5
import type { CreateGitBookOptions } from '@gitbook/embed' ;
5
6
import type { NextRequest } from 'next/server' ;
@@ -14,7 +15,6 @@ export async function GET(
14
15
{ params } : { params : Promise < RouteLayoutParams > }
15
16
) {
16
17
const { context } = await getEmbeddableStaticContext ( await params ) ;
17
- const maxAge = 7 * 24 * 60 * 60 ;
18
18
const initOptions : CreateGitBookOptions = {
19
19
siteURL : context . linker . toAbsoluteURL ( context . linker . toPathInSite ( '' ) ) ,
20
20
} ;
@@ -45,13 +45,13 @@ export async function GET(
45
45
const load = function () {
46
46
const style = document.createElement('link');
47
47
style.rel = 'stylesheet';
48
- style.href = ${ JSON . stringify ( getAssetURL ( ' embed/index.css' ) ) } ;
48
+ style.href = ${ JSON . stringify ( getAssetURL ( ` embed/index.css?v= ${ buildVersion ( ) } ` ) ) } ;
49
49
document.head.appendChild(style);
50
50
51
51
const script = d.createElement('script');
52
52
script.type = 'text/javascript';
53
53
script.async = true;
54
- script.src = ${ JSON . stringify ( getAssetURL ( ' embed/index.js' ) ) } ;
54
+ script.src = ${ JSON . stringify ( getAssetURL ( ` embed/index.js?v= ${ buildVersion ( ) } ` ) ) } ;
55
55
56
56
var latestScript = d.getElementsByTagName('script')[0];
57
57
latestScript.parentNode.insertBefore(script, latestScript);
@@ -70,7 +70,7 @@ export async function GET(
70
70
{
71
71
headers : {
72
72
'Content-Type' : 'application/javascript' ,
73
- 'Cache-Control' : ` public, max-age=${ maxAge } , immutable` ,
73
+ 'Cache-Control' : ' public, max-age=86400, stale-while-revalidate=604800' ,
74
74
} ,
75
75
}
76
76
) ;
0 commit comments