首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apostrophe CMS的性能工程

Apostrophe CMS的性能工程
EN

Stack Overflow用户
提问于 2016-11-04 22:23:37
回答 1查看 384关注 0票数 0

因此,在12小时轮班3周后,我几乎完成了使用Apostrophe构建知识库系统的工作。现在的任务是加速前端的事情。我的问题是:

  1. 如何添加Express :Express有一个名为static的内置中间件,我可以在index.js文件下正常地实现它吗?
  2. Minify JavaScript & CSS:http://apostrophecms.org/docs/modules/apostrophe-assets/我看到撇号有内置的东西,但不清楚如何启用它?此外,我还需要将资产放在特定的文件夹中才能工作吗?现在,我拥有lib/modules/apostrophe-page/public/ JS和public/css下的所有js文件。
  3. 在服务器上启用GZIP :没有提到什么,但是express确实有gzip模块,我能在lib/ modules /apostrophe/index.js下实现它们吗?

任何帮助都将受到极大的感谢。

EN

回答 1

Stack Overflow用户

发布于 2016-11-05 14:52:42

我是彭克大街Apostrophe的首席开发者。

听起来您已经找到了我们的部署方法,最近添加了关于小型化的内容,所以您已经自己解决了这个问题。那很好。

至于服务器上的过期标头和gzip,您可以直接在节点中这样做,但我们不会这样做!一般来说,我们从来没有直接与终端用户进行节点对话。相反,我们使用nginx作为反向代理,它为我们提供了负载平衡,并允许我们直接交付静态文件。用C/C++编写的nginx在这方面更快。此外,gzip和TLS的实现也是经过了大量的战斗测试。不需要让javascript做它不擅长的事情。

我们通常使用机械师配置nginx,我们创建它是为了使用一些命令来管理nginx,而不是手工编写配置文件。我们的标准配方包括gzip和。

但是,下面是它创建的nginx配置文件的注释版本。您将看到它涵盖了静态文件的负载平衡、gzip和更长的过期时间。

代码语言:javascript
复制
# load balance across 4 instances of apostrophe listening on different ports
upstream upstream-example {
  server localhost:3000;
  server localhost:3001;
  server localhost:3002;
  server localhost:3003;
}

server {
  # gzip transfer encoding
  gzip on;
  gzip_types text/css text/javascript image/svg+xml
    application/vnd.ms-fontobject application/x-font-ttf
    application/x-javascript application/javascript;

  listen *:80;

  server_name www.example.com example.com;

  client_max_body_size 32M;

  access_log /var/log/nginx/example.access.log;
  error_log /var/log/nginx/example.error.log;

   # reverse proxy: pass requests to nodejs backends        
  location @proxy-example-80 {
    proxy_pass http://upstream-example;

    proxy_next_upstream error timeout invalid_header http_500 http_502
  http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

  # Deliver static files directly if they exist matching the URL,
  # if not proxy to node
  location / {
    root /opt/stagecoach/apps/example/current/public/;
    try_files $uri @proxy-example-80;
    # Expires header: 7-day lifetime for static files
    expires 7d;
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40432532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档