简体   繁体   English

在IBM Cloud Foundry中运行nodejs app时,文件不会压缩

[英]Files don't compress when run nodejs app in IBM cloud foundry

So I have simple express app. 所以我有简单的快递应用程序。 When it run locally, I can see js, css files got gzip compressed but when I deploy to cloud foundry, those files not compressed. 当它在本地运行时,我可以看到js,css文件被gzip压缩但是当我部署到云代工厂时,这些文件没有被压缩。 The files size still the same. 文件大小仍然相同。 Anyone know the reason, how to fix it or solutions for this issue ? 任何人都知道原因,如何解决它或解决这个问题?

const express = require('express');
const compression = require('compression');
const app = express();

app.use(compression());
app.use(express.static('./public'));

Package.json 的package.json

{
  "name": "conversation-simple",
  "description": "A simple Node.js based web app which shows how to use the Conversation API to recognize user intents.",
  "version": "0.1.1",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "@google/chatbase": "^1.1.2",
    "body-parser": "^1.18.2",
    "botbuilder": "^3.15.0",
    "cloudant": "^1.10.0-NOTICE",
    "compression": "^1.7.3",
    "cors": "^2.8.4",
    "dotenv": "^2.0.0",
    "express": "^4.16.1",
    "gulp-rename": "^1.4.0",
    "moment": "^2.22.2",
    "nano": "^6.4.4",
    "request": "^2.87.0",
    "slick-carousel": "^1.8.1",
    "underscore": "^1.9.0",
    "universal-analytics": "^0.4.16",
    "watson-developer-cloud": "^3.5.3",
    "xml-js": "^1.6.3"
  },
  "engines": {
    "node": "8.15.x"
  }
}

Update: 更新:

Look like there is location problem. 看起来有位置问题。 When it's deployed to Sydney, the compression doesn't work but Dallas is ok. 当它部署到悉尼时,压缩不起作用,但达拉斯没问题。 IBM support have confirmed the issue in my ticket and currently investigate. IBM支持已在我的机票中确认了该问题并且目前正在调查。

I have the same issue, I feel like I've tried absolutely everything so far: Static Gzipping (serving .gz files) Brotli (no dice) Dynamic compression (like you) Redirect to static .gz files 我有同样的问题,我觉得到目前为止我已经尝试了一切:静态Gzipping(服务.gz文件)Brotli(没有骰子)动态压缩(像你一样)重定向到静态.gz文件

It works locally as it should but once deployed - farting noise nothing. 它本地应用,但一旦部署 - 放屁噪声

I have a feeling it happens in the proxy and needs to be enabled somewhere, where is not documented though 我感觉它发生在代理中,需要在某处启用,但是没有记录

Commenting here to follow this, also I've contacted their support, if I get any answers I will put them here :) 在这里评论这个,我也联系了他们的支持,如果我得到任何答案,我会把它们放在这里:)

This issue was fixed by IBM. 这个问题由IBM修复。

"After investigation, we found an issue that strips the header and decompresses the response in the Cloud Foundry Platform AU-SYD region." “经过调查,我们发现了一个问题,它剥离了标头并解压缩了Cloud Foundry Platform AU-SYD区域的响应。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM