Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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

{
  "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.

like image 635
DarknessZX Avatar asked Nov 07 '22 17:11

DarknessZX


1 Answers

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

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 :)

like image 130
Mikkel Graph Petersen Avatar answered Nov 13 '22 21:11

Mikkel Graph Petersen