本文整理匯總了TypeScript中serve-static.mime類的典型用法代碼示例。如果您正苦於以下問題:TypeScript mime類的具體用法?TypeScript mime怎麽用?TypeScript mime使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了mime類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: if
setHeaders: (response, path) => {
if (ServeStatic.mime.lookup(path) === "text/html") {
// don't cache html
response.setHeader("Cache-Control", "no-cache");
}
else if (/\/(css|javascript)$/.test(ServeStatic.mime.lookup(path))) {
// cache css and javascript for a year as we bust it automatically
response.setHeader("Cache-Control", "public, max-age=31536000");
}
}
示例2: express
import * as express from 'express';
import * as serveStatic from 'serve-static';
var app = express();
app.use(serveStatic('/1'));
app.use(serveStatic('/2', { }));
app.use(serveStatic('/3', {
dotfiles: 'ignore',
etag: true,
extensions: ['html'],
fallthrough: true,
index: true,
lastModified: true,
maxAge: 0,
redirect: true,
setHeaders: function(res: express.Response, path: string, stat: any) {
res.setHeader('Server', 'server-static middleware');
}
}));
serveStatic.mime.define({
'application/babylon': ['babylon'],
'application/babylonmeshdata': ['babylonmeshdata'],
'application/fx': ['fx']
});