Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
request-etag
Advanced tools
Small, in-memory, ETag-based, HTTP-response-caching module. It is based on the two following popular NPM packages,
request-etag
constructor.Configuration,
var cacheConfig = {
max: 10 * 1024 * 1024
};
A default length
function is injected into the cache object by request-etag
. It returns the sum of the length of the key, and the length of the value as JSON.
More details on the cache configuration options can be found on the lru-cache webpage.
var ETagRequest = require('request-etag');
var eTagRequest = new ETagRequest(cacheConfig);
The ETagRequest
constructor takes a second optional argument which specifies the underlying HTTP request client to use. It defaults to request, so the above constructor call is equivalent to,
var eTagRequest = new ETagRequest(cacheConfig, require('request'));
Note that the signature of the underlying HTTP request client function MUST be the same as that of request (e.g. requestretry).
The first GET request will be sent without an If-None-Match
header, and its response will contain a body.
eTagRequest('www.immutablepage.com', function (error, response, body) {
if (!error && response.statusCode === 200) {
console.log('Received 200 - body retrieved from response.');
console.log(body);
}
if (!error && response.statusCode === 304) {
console.log('Received 304 - body retrieved from cache.')
console.log(body);
}
});
Subsequent GET requests to the same URL will be sent with an If-None-Match
header. The response code will be 304, and the response will not contain a body. However a body will be passed by the cache to the body
parameter of the callback function.
Situations where the request response is not cached include,
Please run the following commands before submitting a pull-request,
npm run lint
npm run code-style
npm run test
FAQs
Small, ETag-based, HTTP-response-caching module
We found that request-etag demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.