Releases

v12.0.0 Feb 21, 2024

v12.0.0 Removing support of Nodjs 16.

cacheable-request now only supports nodejs 18+

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable/compare/v11.0.0...v12.0.0

v11.0.0 Jan 19, 2024

Cacheable-Request v11.0.0

This release has added support for Nodejs v20+, fixing source map issues, and a major upgrade to get-stream v8+ and more. All functionality should remain the same but is a significant update that needs to validated with your use case. Any questions or concerns please log an issue here: https://github.com/jaredwray/cacheable/issues

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable/compare/v10.2.12...v11.0.0

2023-10-05 Oct 05, 2023

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable/compare/2023-09-05...2023-10-05

2023-09-05 Sep 05, 2023

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable/compare/2023-07-26...2023-09-05

2023-07-26 Jul 26, 2023

cacheable-request v10.2.13

Mono Repo

We have now moved to a mono repo and also launched a new website https://cacheable.org. Our plan is now to build out cacheable request version with HTTP 2 support as a new module in addition other caching libraries. 🎉

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable/compare/v10.2.12...2023-07-26

v10.2.12 Jun 22, 2023

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.11...v10.2.12

v10.2.11 Jun 20, 2023

Major Changes Made

  • Upgraded get-stream to 7.0.0 and now using getStreamAsBuffer
  • Removed support for Nodejs 14 as it is incompatible with GOT and get-stream

NOTE: testing has started with Nodejs version 20 and there is an issue that we are working to resolve in the next month https://github.com/jaredwray/cacheable-request/issues/251

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.10...v10.2.11

v10.2.10 Apr 25, 2023

Code Cleanup

In this release there were minor code clean up with how we identified undefined values. Nothing major.

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.8...v10.2.10

v10.2.8 Feb 23, 2023

Updated body-parser to 1.20.2 - release notes here https://github.com/expressjs/body-parser/releases/tag/1.20.2

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.6...v10.2.8

v10.2.6 Feb 02, 2023

Fix for memory leak on Listeners

The listener was not being removed on response and just error but new handlers were being added causing a memory leak.

line 220 in src/index.ts was modified to remove the listener on response also

			if (this.cache instanceof Keyv) {
				const cachek = this.cache;
				cachek.once('error', errorHandler);
				ee.on('error', () => cachek.removeListener('error', errorHandler));
				ee.on('response', () => cachek.removeListener('error', errorHandler));
			}

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.5...v10.2.6

v10.2.5 Jan 05, 2023

Types definition issue with http-cache-sematics as that type definition needs to be in dependencies. Thanks @Maxim-Mazurok

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.4...v10.2.5

v10.2.4 Dec 23, 2022

v10.2.4

Minor updates with one exception is that we removed @types/http-cache-semantics from the main dependencies as it does not look to be needed.

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.3...v10.2.4

v10.2.3 Nov 22, 2022

v10.2.3 Maintenance Release

Upgrading core modules in the system such as keyv and also a minor fix to an uncaught exception that we were seeing referenced here: https://github.com/sindresorhus/got/issues/1925

Additional update is moving normalize-url to 8.0.0 which after testing it looks to not affect anything but will post the release notes here: https://github.com/sindresorhus/normalize-url/releases/tag/v8.0.0

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.2...v10.2.3

v10.2.2 Oct 19, 2022

Maintenance Release 10.2.2 🛠️

This is a monthly maintenance release which focused mostly on development toolset and should not have any big changes. The only package that was updated is normalize-url with a version bump to 7.2.0.

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.1...v10.2.2

v10.2.1 Sep 26, 2022

10.2.1 Bug fixes and Changes

Biggest change has been that when an agent is KeepAlive: true we are now sending a response end which will close the socket instead of an error.

What’s Changed

New Contributors

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.2.0...v10.2.1

v10.2.0 Sep 23, 2022

Hooks onResponse replacing response hook

response will still work but will be deprecated as we expand this functionality. onResponse will be the name moving forward. Here are examples of how to use it.

How to decompress

import http from 'http';
import CacheableRequest from 'cacheable-request';

const cacheableRequest = new CacheableRequest(request, cache).request();

// adding a hook to decompress response
cacheableRequest.addHook('onResponse', async (value: CacheValue, response: any) => {
  const buffer = await pm(gunzip)(value.body);
  value.body = buffer.toString();
  return value;
});

how to add a remote address

import CacheableRequest, {CacheValue} from 'cacheable-request';

const cacheableRequest = new CacheableRequest(request, cache).request();
cacheableRequest.addHook('onResponse', (value: CacheValue, response: any) => {
  if (response.connection) {
    value.remoteAddress = response.connection.remoteAddress;
  }

  return value;
});

In addition to that we have also updated some of the packages to their lates which you can read below 👇

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.1.2...v10.2.0

v10.1.2 Sep 16, 2022

⚠️ Breaking Change

Based on feedback (thanks @szmarczak!) we have renamed the function createCacheableRequest to just request.

- const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
+ const cacheableRequest = new CacheableRequest(https.request).request(); 

v10 code with createCacheableRequest

import CacheableRequest from 'cacheable-request';

// Now You can do
const cacheableRequest = new CacheableRequest(http.request).request();
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid

// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
const cacheableRequest = new CacheableRequest(electron.net).createCacheableRequest();

v10.1.2 code with request

import CacheableRequest from 'cacheable-request';

// Now You can do
const cacheableRequest = new CacheableRequest(http.request).request();
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid

// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request).request();
const cacheableRequest = new CacheableRequest(electron.net).request();

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.0.2...v10.1.2

v10.0.2 Sep 14, 2022

Change to support got by exporting types enabling better integration with upstream packages.

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.0.1...v10.0.2

v10.0.1 Sep 11, 2022

Minor maintenance release with some primary packages updated such as:

  • @types/node to 18.7.16
  • keyv to 4.5.0
  • normalize-url to 7.10

Changelog

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v10.0.0...v10.0.1

v10.0.0 Sep 10, 2022

Breaking Change with v10.0.0

This release contains breaking changes as we are now using class to handle instances and hooks better. This is the new way to use this package.

Usage Before v10

import http from 'http';
import CacheableRequest from 'cacheable-request';

// Then instead of
const req = http.request('http://example.com', cb);
req.end();

// You can do
const cacheableRequest = new CacheableRequest(http.request);
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid

// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request);
const cacheableRequest = new CacheableRequest(electron.net);

Usage After v10

import CacheableRequest from 'cacheable-request';

// Now You can do
const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid

// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
const cacheableRequest = new CacheableRequest(electron.net).createCacheableRequest();

The biggest change is that when you do a new CacheableRequest you now want to call createCacheableRequest method will give you the instance to use.

- const cacheableRequest = new CacheableRequest(http.request);
+ const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();

What’s Changed

New Contributors

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v9.0.0...v10.0.0

v9.0.0 Aug 13, 2022

v9 is now pure ESM 🎉

cacheable-request is now pure ESM with version v9.0.0 and up. Version v.8.x.x is the supported commonjs version which will get only major security fixes moving forward until end of 2022. If you would like to learn about uprgrading / using ESM @sindresorhus has an amazing reference guide here: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Major thank you to @alphmth, @sindresorhus, @szmarczak, @jasonbaik, and everybody for help on this. 🙌

Special call out to @CyberShadow as in the previous release we forgot to mention the work done on issue #28 as without their guidance and code we wouldn’t have fixed it. ❤️

Typescript

In addition to pure ESM we are now fulling using Typescript moving forward on this project which means all type definitions are now native with the service. 🤩

Hooks!

Hooks have been introduced for the response object that will run a processing function like so if you wanted to do compression:

CacheableRequest.addHook('response', async (response: any) => {
  const buffer = await pm(gunzip)(response);
  return buffer.toString();
});

const cacheableRequest = CacheableRequest(request, cache);

How to Add a Hook: https://github.com/jaredwray/cacheable-request#add-hooks How to Remove a Hook: https://github.com/jaredwray/cacheable-request#remove-hooks

We would love some feedback on this feature!

Change Log

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v8.3.1...v9.0.0

v8.0.1 Jun 11, 2022

What’s Changed

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v8.0.0...v8.0.1

v8.0.0 Jun 11, 2022

What’s Changed

New Contributors

Full Changelog: https://github.com/jaredwray/cacheable-request/compare/v7.0.2...v8.0.0

Jun 09, 2021