@@ -11,6 +11,7 @@ import index from './render/index.html.ts'
11
11
import feed from './render/feed.xml.ts'
12
12
import blogPost from './render/blog-post.html.ts'
13
13
import CleanCSS from "./deps/clean-css.ts" ;
14
+ import { ONE_HOUR , ONE_MINUTE } from './utils/misc.ts' ;
14
15
15
16
const SIMPLE_PAGES = {
16
17
'404' : fourOhFour ,
@@ -20,6 +21,9 @@ const SIMPLE_PAGES = {
20
21
'feed.xml' : feed
21
22
} as const
22
23
24
+ const ONE_MINUTE_S = ONE_MINUTE / 1000
25
+ const ONE_HOUR_S = ONE_HOUR / 1000
26
+
23
27
export const createFileMap = async ( ) => {
24
28
const fileMap = new Map < string , { content : Uint8Array , headers : HeadersInit } > ( )
25
29
const encoder = new TextEncoder ( )
@@ -47,7 +51,7 @@ export const createFileMap = async () => {
47
51
content : allCSSArray ,
48
52
headers : {
49
53
'Content-Type' : CONTENT_TYPES . css ,
50
- 'Cache-Control' : `max-age=${ 60 * 60 } `
54
+ 'Cache-Control' : `max-age=${ ONE_HOUR_S } `
51
55
}
52
56
} )
53
57
}
@@ -62,7 +66,7 @@ export const createFileMap = async () => {
62
66
content,
63
67
headers : {
64
68
'Content-Type' : CONTENT_TYPES [ fileExtension ] ,
65
- 'Cache-Control' : `max-age=${ 60 * 60 } `
69
+ 'Cache-Control' : `max-age=${ ONE_HOUR_S } `
66
70
}
67
71
} )
68
72
}
@@ -80,7 +84,8 @@ export const createFileMap = async () => {
80
84
fileMap . set ( `/${ pageName } ` , {
81
85
content : encoder . encode ( render ( { allTags, posts } ) ) ,
82
86
headers : {
83
- 'Content-Type' : CONTENT_TYPES . html
87
+ 'Content-Type' : CONTENT_TYPES . html ,
88
+ 'Cache-Control' : `max-age=${ ONE_MINUTE_S } `
84
89
}
85
90
} )
86
91
}
@@ -89,7 +94,8 @@ export const createFileMap = async () => {
89
94
fileMap . set ( '/' , {
90
95
content : encoder . encode ( index ( { allTags, posts } ) ) ,
91
96
headers : {
92
- 'Content-Type' : CONTENT_TYPES . html
97
+ 'Content-Type' : CONTENT_TYPES . html ,
98
+ 'Cache-Control' : `max-age=${ ONE_MINUTE_S } `
93
99
}
94
100
} )
95
101
@@ -98,7 +104,8 @@ export const createFileMap = async () => {
98
104
const file = {
99
105
content : encoder . encode ( index ( { allTags, posts, tag } ) ) ,
100
106
headers : {
101
- 'Content-Type' : CONTENT_TYPES . html
107
+ 'Content-Type' : CONTENT_TYPES . html ,
108
+ 'Cache-Control' : `max-age=${ ONE_MINUTE_S } `
102
109
}
103
110
}
104
111
@@ -111,7 +118,8 @@ export const createFileMap = async () => {
111
118
const file = {
112
119
content : encoder . encode ( blogPost ( { post } ) ) ,
113
120
headers : {
114
- 'Content-Type' : CONTENT_TYPES . html
121
+ 'Content-Type' : CONTENT_TYPES . html ,
122
+ 'Cache-Control' : `max-age=${ ONE_MINUTE_S } `
115
123
}
116
124
}
117
125
0 commit comments