System on firebase functions always have problems that code start. https://medium.com/@siriwatknp/cold-start-workaround-in-firebase-cloud-functions-8e9db1426bd3 So google office https://firebase.google.com/docs/functions/networking const http = require('http'); const functions = require('firebase-functions'); // Setting the `keepAlive` option to `true` keeps // connections open between function invocations const agent = new http.Agent({keepAlive: true}); exports.function = functions.https.onRequest((request, response) => { req = http.request({ host: '', port: 80, path: '', method: 'GET', agent: agent, // Holds the connection open after the first invocation }, res => { let rawData = ''; res.

繼續閱讀

https://sematext.com/blog/expressjs-best-practices/``` const express = require(‘express’) const app = express() const redis = require(‘redis’) ​ const redisClient = redis.createClient(6379) ​ async function getSomethingFromDatabase (req, res, next) { try { const { id } = req.params; const data = await database.query() ​ // Set data to Redis redisClient.setex(id, 3600, JSON.stringify(data)) res.status(200).send(data) } catch (err) { console.error(err) res.status(500) } } ​ function cache (req, res, next) { const { id } = req.

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan