
Security News
New CNA Scorecard Tool Ranks CVE Data Quality Across the Ecosystem
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
@polka/compression
Advanced tools
Fast gzip+brotli compression middleware for polka & express with zero dependencies.
An HTTP response compression middleware that supports native Gzip and Brotli. Works with Polka and Express!
$ npm install --save @polka/compression
const polka = require('polka');
const compression = require('@polka/compression');
polka()
.use(compression({ /* see options below */ }))
.use((req, res) => {
// this will get compressed:
res.end('hello world!'.repeat(1000));
})
.listen();
compression(options?: Options): Middlware
The compression
function creates a Polka/Express-compatible middleware function. When no options
are defined, the defaults are used.
All options use a default value when a value is not defined.
Type: Number
Default: 1024
Responses below this threshold (in bytes) are not compressed. The default value of 1024
is recommended, and avoids sharply diminishing compression returns.
Type: Number
Default: -1
The compression effort/level/quality setting, used by both Gzip and Brotli. The scale ranges from 1
to 11
, where lower values are faster and higher values produce smaller output.
The default value of -1
uses the default compression level as defined by Gzip (6
) and Brotli (6
).
Type: boolean
Default: false
Enables response compression using Brotli for requests that support it.
Brotli incurs more performance overhead than Gzip, which is why it's not enabled by default.
Type: boolean
Default: true
Enables response compression using Gzip for requests that support it, as determined by the Accept-Encoding
request header.
Type: RegExp
Default: /text|javascript|\/json|xml/i
The Content-Type
response header is evaluated against this Regular Expression to determine if it is a MIME type that should be compressed.
NOTE: Remember that compression is (generally) only effective on textual content.
Any issues or questions can be sent to the Polka repository.
However, please specify that your inquiry is about @polka/compression
specifically.
MIT
FAQs
Fast gzip+brotli compression middleware for polka & express with zero dependencies.
We found that @polka/compression demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.