Performance updates for sling-connector
Improvements to implement
- Custom request agent to allow keep-alive
- Prevent any call that starts with
/undefined
or/[object Object]
- If configured append the
get-if-exists
selector to all standard.<number>.json
calls (see https://gitlab.entropy.cc/entropy/foss-sling/issues/12#) - Add an in memory cache layer. This is to stop the sling-connector from having to make the same request over an over within the page request. This should likewise be configurable.
- Enable GZIP compression for all requests to Sling
Implementation Notes
Custom Request Agent
Node module: https://www.npmjs.com/package/agentkeepalive At the top of the sling-connector.js, create a global agent object
this.keepaliveAgent = new Agent({
maxSockets: 1000,
maxFreeSockets: 256, // default
timeout: 40000, // active socket keepalive for 40 seconds
freeSocketTimeout: 20000, // free socket keepalive for 20 seconds
});
and add it to the options of the two request methods in that file.
..
agent: sc_self.keepaliveAgent,
..