【问题标题】:When using meteor with MUP and NGINX how should I setup my cache?当使用 MUP 和 NGINX 的流星时,我应该如何设置我的缓存?
【发布时间】:2014-12-06 00:25:26
【问题描述】:

现在我正在我的 .conf 文件中尝试这个。如果我这样做,所有图片都不会显示。

location ~*  \.(jpg|jpeg|png|gif|ico)$ {
    expires 365d;
}

location ~*  \.(pdf)$ {
    expires 30d;
}

我已经在 SO 上查看过这个问题 (https://stackoverflow.com/a/18039576/582309),但它并没有解决我在使用 MUP 时遇到的问题。

我还尝试包含 MUP 正在创建的构建目录的根路径,但这也不起作用。另外,我在这里从缓存中删除了 CSS 和 JS,因为如果它们不起作用,页面将不会加载,而且我不确定 Meteor 是否已经在处理这些文件的缓存。

location ~*  \.(jpg|jpeg|png|gif|ico)$ {
    root /opt/give/app/programs/web.browser; //tried many combinations of the path
    expires 365d;
}

location ~*  \.(pdf)$ {
    expires 30d;
}

这是 .conf 文件其余部分的 GIST

Sites.conf GIST

https://gist.github.com/c316/9552ecdc8107334fc55d

位置特定要点

https://gist.github.com/c316/4917d95cbfddd3e181ad

【问题讨论】:

  • @Stephan 是您的根路径 MUP 的路径,还是您存储 git 存储库的位置,还是其他?
  • 另外,我在 /give 的不同 root_url 运行流星,而不仅仅是根 url 或 / 所以我不知道这是否会影响缓存。
  • MUP 部署到 /home/meteor/。有没有查看 nginx 的错误日志,看看是什么问题?
  • @Stephan MUP 没有部署到我服务器上的那个目录。它正在部署到 /opt/give/app/programs/web.browser。这是错误日志中的内容。 11.11.11.11 - - [02/Dec/2014:20:21:42 -0600] "GET /give/images/check_image.png HTTP/1.1" 404 570 "trashmountain.com/give"

标签: nginx meteor meteor-up


【解决方案1】:

事实证明,要缓存我的图像字体和其他公共资产,我确实需要这样做。

已经有这个顶部

location /give {
    proxy_pass http://trashmountainGive/app_name;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;

    proxy_redirect off;

    #Added everything below here

    location /give/images {
        alias /opt/app_name/app/programs/web.browser/app/images;
        access_log off;
        expires max;
    }

    location /give/fonts {
        alias /opt/app_name/app/programs/web.browser/app/fonts;
        access_log off;
        expires max;
    }
}

查看这篇文章

http://nginx.com/blog/nginx-nodejs-websockets-socketio/

向下滚动到“静态文件呢?”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多