FeathersJS加载静态内容缓慢

时间:2018-06-24 02:51:47

标签: express feathersjs

羽毛/ Express加载静态内容的速度确实很慢。没有使用Nginx可以加快速度吗?对于ADSL连接上200-300kb的文件(下载速度为20mbps),每次加载图像的请求大约需要3秒钟。我尝试重新排序中间件没有任何运气,我真的没什么可说的,但是我的帖子主要是代码。

我的App.js:

const path = require('path');
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const helmet = require('helmet');
const logger = require('winston');
const hbs = require('hbs');

const feathers = require('@feathersjs/feathers');
const configuration = require('@feathersjs/configuration');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');

const middleware = require('./middleware');
const services = require('./services');
const appHooks = require('./app.hooks');
const channels = require('./channels');

const authentication = require('./authentication');

const mongodb = require('./mongodb');

require('dotenv').config();

const app = express(feathers());

// Load app configuration
app.configure(configuration());

// Host the public folder
app.use('/', express.static(app.get('public'), { maxAge: '30d' }));

// Enable CORS, security, compression, favicon and body parsing
app.use(cors());
app.use(helmet());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(favicon(path.join(app.get('public'), 'favicon.ico')));

// Set template engine
app.set('view engine', 'hbs');

// Set up Plugins and providers
app.configure(express.rest());
app.configure(socketio());

app.configure(mongodb);

// Configure other middleware (see `middleware/index.js`)
app.configure(middleware);
app.configure(authentication);
// Set up our services (see `services/index.js`)
app.configure(services);
// Set up event channels (see channels.js)
app.configure(channels);

// Configure a middleware for 404s and the error handler
app.use(express.notFound());
app.use(express.errorHandler({ logger }));

app.hooks(appHooks);

module.exports = app;

0 个答案:

没有答案