Feat: cache static files

This commit is contained in:
Bluemangoo 2023-03-11 20:06:17 +08:00 committed by GitHub
parent 160a4e293b
commit 49cb682d48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,7 +164,10 @@ _ / / / / /___ ____/ /_ / / / / /_/ /_ / / / /_/ /_ /_/ // __/ /
app.use(protocolMiddleware);
// static file routing
app.use(koaStatic(path.join(BASE_PATH, "public")));
const koaStaticOptions = {
maxAge: 10 * 24 * 60 * 60 //Cache for ten days. Changed files will not be load from cache.
};
app.use(koaStatic(path.join(BASE_PATH, "public"), koaStaticOptions));
// Websocket routing (useless for now)
// import SocketService from "./app/service/socket_service";