11import type { RouteLayoutParams } from '@/app/utils' ;
22import { getAssetURL } from '@/lib/assets' ;
3+ import { buildVersion } from '@/lib/build' ;
34import { getEmbeddableStaticContext } from '@/lib/embeddable' ;
45import type { CreateGitBookOptions } from '@gitbook/embed' ;
56import type { NextRequest } from 'next/server' ;
@@ -14,7 +15,6 @@ export async function GET(
1415 { params } : { params : Promise < RouteLayoutParams > }
1516) {
1617 const { context } = await getEmbeddableStaticContext ( await params ) ;
17- const maxAge = 7 * 24 * 60 * 60 ;
1818 const initOptions : CreateGitBookOptions = {
1919 siteURL : context . linker . toAbsoluteURL ( context . linker . toPathInSite ( '' ) ) ,
2020 } ;
@@ -45,13 +45,13 @@ export async function GET(
4545 const load = function () {
4646 const style = document.createElement('link');
4747 style.rel = 'stylesheet';
48- style.href = ${ JSON . stringify ( getAssetURL ( ' embed/index.css' ) ) } ;
48+ style.href = ${ JSON . stringify ( getAssetURL ( ` embed/index.css?v= ${ buildVersion ( ) } ` ) ) } ;
4949 document.head.appendChild(style);
5050
5151 const script = d.createElement('script');
5252 script.type = 'text/javascript';
5353 script.async = true;
54- script.src = ${ JSON . stringify ( getAssetURL ( ' embed/index.js' ) ) } ;
54+ script.src = ${ JSON . stringify ( getAssetURL ( ` embed/index.js?v= ${ buildVersion ( ) } ` ) ) } ;
5555
5656 var latestScript = d.getElementsByTagName('script')[0];
5757 latestScript.parentNode.insertBefore(script, latestScript);
@@ -70,7 +70,7 @@ export async function GET(
7070 {
7171 headers : {
7272 'Content-Type' : 'application/javascript' ,
73- 'Cache-Control' : ` public, max-age=${ maxAge } , immutable` ,
73+ 'Cache-Control' : ' public, max-age=86400, stale-while-revalidate=604800' ,
7474 } ,
7575 }
7676 ) ;
0 commit comments