Thank you for the feedback!
In my case (I use Adobe IO for SSR), doing some comparison checks on similar clients, I notice that the pages could go up to 2MB (conservatively), so the general 1MB limit is really not much.
Reasoning absurdly, I ask myself: even if we go up to 1MB per page, does it really make sense to let 1MB pass through the network rather than compress?
Then compression could solve my issue, but it is not clear if/how to activate it in Adobe I/O SSR then discuss with the customer on the CPU implications (Adobe IO / AEM publish) https://www.conduktor.io/kafka/kafka-message-compression
Thank for your feedback about this. The only way to activate it within Adobe I/O I think is to create a Runtime as in this example in which we could use gzip and brotli to compress payload and response. As I said the only implication is CPU usage.
/**
* Generate an `OK` response, which is potentially compressed, based on request headers.
* @param {Object} requestHeaders The original request headers.
* @param {Object} payload The response JSON payload.
* @param {Object} additionalHeaders Optional additional response headers to set.
* @returns {Object} a response object.
*/
function compressedSuccess(
requestHeaders = {},
payload = {},
additionalHeaders = {},
) {
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
const accept = Accept.encoding(requestHeaders['accept-encoding'], ENCODING_PREFERENCE);
let compressionHeaders = {};
let raw;
switch (accept) {
case ENCODING_BR:
raw = zlib.brotliCompressSync(json2Buffer(payload), COMPRESSION_OPTS);
break;
case ENCODING_GZIP:
raw = zlib.gzipSync(json2Buffer(payload), COMPRESSION_OPTS);
break;
case ENCODING_DEFLATE:
raw = zlib.deflateSync(json2Buffer(payload), COMPRESSION_OPTS);
break;
default:
raw = { payload };
}
// response body is compressed, add relevant headers
// also, openwhisk requires binary responses to be base64 encoded
if (accept !== ENCODING_IDENTITY) {
compressionHeaders = {
'Content-Encoding': accept,
Vary: 'Accept-Encoding',
};
raw = raw.toString('base64');
}
return createRawResponse(
HttpStatus.OK,
raw,
{
...JSON_RESPONSE_HEADERS,
...compressionHeaders,
...additionalHeaders,
},
);