this.zip_cache.kick()
}
-Site.prototype.serve_internal = function(response, status, mime_type, data) {
+Site.prototype.serve_internal = function(response, status, mime_type, caching, data) {
response.statusCode = status
// html files will be direct recipient of links/bookmarks so can't have
// a long lifetime, other files like css or images are often large files
// and won't change frequently (but we'll need cache busting eventually)
- if (this.options.caching && mime_type !== this.options.mime_type['.html'])
+ if (caching && mime_type !== this.options.mime_type['.html'])
response.setHeader('Cache-Control', 'max-age=3600')
response.setHeader('Content-Type', mime_type)
response.setHeader('Content-Length', data.length)
console.log(
`${env.parsed_url.host} serving ${env.parsed_url.pathname} size ${data.length} from ${from}`
)
- this.serve_internal(env.response, status, env.mime_type, data)
+ this.serve_internal(env.response, status, env.mime_type, env.caching, data)
}
Site.prototype.die = function(env, message) {
env.response,
404,
this.options.mime_types['.html'],
+ false,
Buffer.from(
`<html>
<head>
env.response,
301,
this.options.mime_types['.html'],
+ false,
Buffer.from(
`<html>
<head>
Site.prototype.respond = async function(env) {
env.mime_type = 'application/octet-stream'
+ env.caching = this.options.caching
let pathname = decodeURIComponent(env.parsed_url.pathname)
let i = pathname.lastIndexOf('.')
if (i !== -1) {