@@ -8,7 +8,7 @@ import { getContentType } from "../lib/mime.ts";
8
8
import util from "../lib/util.ts" ;
9
9
import { errorHtml } from "./error.ts" ;
10
10
import { DependencyGraph } from "./graph.ts" ;
11
- import { getDeploymentId , initModuleLoaders , loadImportMap , loadJSXConfig } from "./helpers.ts" ;
11
+ import { getDeploymentId , initModuleLoaders , loadImportMap , loadJSXConfig , regFullVersion } from "./helpers.ts" ;
12
12
import { type HTMLRewriterHandlers , loadAndFixIndexHtml } from "./html.ts" ;
13
13
import renderer , { type SSR } from "./renderer.ts" ;
14
14
import { content , type CookieOptions , json , setCookieHeader } from "./response.ts" ;
@@ -53,7 +53,7 @@ export const serve = (options: ServerOptions = {}) => {
53
53
} ) ;
54
54
const handler = async ( req : Request , connInfo : ConnInfo ) : Promise < Response > => {
55
55
const url = new URL ( req . url ) ;
56
- const { host, pathname } = url ;
56
+ const { host, pathname, searchParams } = url ;
57
57
58
58
if ( pathname === "/-/hmr" ) {
59
59
const { socket, response } = Deno . upgradeWebSocket ( req , { } ) ;
@@ -150,6 +150,9 @@ export const serve = (options: ServerOptions = {}) => {
150
150
}
151
151
headers . append ( "ETag" , etag ) ;
152
152
}
153
+ if ( searchParams . get ( "v" ) || regFullVersion . test ( pathname ) ) {
154
+ headers . append ( "Cache-Control" , "public, max-age=31536000, immutable" ) ;
155
+ }
153
156
const file = await Deno . open ( filePath , { read : true } ) ;
154
157
return new Response ( readableStreamFromReader ( file ) , { headers } ) ;
155
158
}
@@ -176,6 +179,7 @@ export const serve = (options: ServerOptions = {}) => {
176
179
}
177
180
}
178
181
182
+ // create context object
179
183
const customHTMLRewriter = new Map < string , HTMLRewriterHandlers > ( ) ;
180
184
const ctx = {
181
185
connInfo,
0 commit comments