jaredwray / cacheable Goto Github PK
View Code? Open in Web Editor NEWWrap native HTTP requests with RFC compliant cache support
Home Page: https://cacheable.org
License: MIT License
Wrap native HTTP requests with RFC compliant cache support
Home Page: https://cacheable.org
License: MIT License
The branch typescript
is to migrate this project from javascript to typescript
. Please feel free to contribute to this branch and pull request as needed. Here are the steps that we would like to take. This will be the v8.3.0
release being planned.
build
dist/index.js
instead of src/index.ts
temporarilyindex.js
to index.ts
-- once this is done and compiling correctly it should be validated and working against this pull request tests. Refer to Migration of index.js to index.ts
below.Migration of tests to typescript
index.ts
instead of dist/index.js
v8.3.0
and releaseindex.js
to index.ts
There are a couple of things that will need to be done here:
clone-response
does not have type definition. I would prefer that we remove this dependency and just look to duplicate the logic in this file. You can look at the project as it is a small amount of code to refactor here.Keyv
is not working correctly with types. Please do a pull request on Keyv to fix this.options
so it is defined correctlyFor this index migration do not worry about code coverage as we will take care of that in a later step.
Currently this is using Ava and it does look like ava supports typescript with some refactoring. In some cases there are additional packages that will need the type definitions added and supported.
Hi. It appears that cached data is being returned even when the cache expires.
The client calls call to a server endpoint (via cacheable-request) which returns a response with Cache-Control: public, max-age=300. When the client makes the same request again, I can see that the server endpoint is only being hit once every five minutes, as expected. I can also see that the response from the server is a 200 with new data and the same Cache-Control header. However, this new data is not returned from cacheable-request. The previously cached version is returned.
I've recently been trying this with the npm "got" package, but I saw the same behaviour using cacheable-request.
Note that I am not setting the strictTtl option.
Is this user error?!
I originally opened an issue on http-cache-semantics, but this can be fixed on here as well.
The full details can be viewed on the original issue i've opened kornelski/http-cache-semantics#35, but I'll copy it for your convenience.
It causes a problem in https://github.com/lukechilds/cacheable-request. Since this is the root cause of the problem, I opened the issue here.
Although milliseconds can have fractions, the fractions in this case are not caused by the division between the numbers, but by float arithmetic problems, it seems to me.
That's the error I'm getting in cacheable-request which is coming from Keyv I think:
Error [CacheError]: ERR value is not an integer or out of range
code snippet in cacheable-request:
let ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined;
if (opts.maxTtl) {
ttl = ttl ? Math.min(ttl, opts.maxTtl) : opts.maxTtl;
}
await this.cache.set(key, value, ttl);
The program gets to this.cache.set()
providing ttl
= response.cachePolicy.timeToLive()
= 1256996.9999999998
for example, and once set()
is executed, the error above is thrown.
In order to trigger this behavior I'm setting private,max-age=4
on cache-control
header in the request, max-age 4 can be changed to any other number that triggers this behavior.
https://github.com/jaredwray/cacheable-request/releases/tag/v8.0.0 is just a list of commits. 90% of the items there are not useful to users. A changelog should clearly document what the user-faceable changes are, especially what the breaking changes are in a major release.
Examples:
Describe the bug
When I'm running the project facing the error " Cannot find namespace 'CacheableRequest' "
node_modules/got/dist/source/core/options.d.ts:870:27 - error TS2503: Cannot find namespace 'CacheableRequest'.
870 get cache(): string | CacheableRequest.StorageAdapter | boolean | undefined;
~~~~~~~~~~~~~~~~
node_modules/got/dist/source/core/options.d.ts:871:31 - error TS2503: Cannot find namespace 'CacheableRequest'.
871 set cache(value: string | CacheableRequest.StorageAdapter | boolean | undefined);
~~~~~~~~~~~~~~~~
node_modules/got/dist/source/core/options.d.ts:1163:35 - error TS2503: Cannot find namespace 'CacheableRequest'.
1163 cache: string | boolean | CacheableRequest.StorageAdapter | undefined;
Please upgrade normalize-url, because of known vulnerabilities:
https://app.snyk.io/vuln/SNYK-JS-NORMALIZEURL-1296539
Version 7.0.1 of normalize-url saw a bugfix for use in Safari. My project only depends on normalize-url through intermediaries like Got and this project. I tried to apply a patch to this project to upgrade normalize-url to 7.0.1, but it appears as of v7 normalize-url is ESM-only.
What's the stance of the maintainers here toward adjusting things to continue to rely on new versions of normalize-url, by supporting ESM imports?
Please upgrade the following to a latest version and fix any ESM errors when testing.
lowercase-keys ^2.0.0 → ^3.0.0
normalize-url ^6.0.1 → ^7.0.3
> xo && nyc ava
Uncaught exception in test/cacheable-request-class.js
test/cacheable-request-class.js:4
3: const Keyv = require('keyv');
4: const CacheableRequest = require('this');
5:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js from /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js not supported.
Instead change the require of /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› Instead change the require of node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (src/index.js:2:646)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (node_modules/this/src/index.js:7:52)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (test/cacheable-request-class.js:4:26)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
✖ test/cacheable-request-class.js exited with a non-zero exit code: 1
Uncaught exception in test/cacheable-request-instance.js
test/cacheable-request-instance.js:9
8: const getStream = require('get-stream');
9: const CacheableRequest = require('this');
10:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js from /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js not supported.
Instead change the require of /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› Instead change the require of node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (src/index.js:2:646)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (node_modules/this/src/index.js:7:52)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (test/cacheable-request-instance.js:9:26)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
✖ test/cacheable-request-instance.js exited with a non-zero exit code: 1
Uncaught exception in test/cache.js
test/cache.js:9
8: const pify = require('pify');
9: const CacheableRequest = require('this');
10: const Keyv = require('keyv');
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js from /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js not supported.
Instead change the require of /Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› Instead change the require of node_modules/lowercase-keys/index.js in /Users/jaredwray/src/github.com/jaredwray/cacheable-request/src/index.js to a dynamic import() which is available in all CommonJS modules.
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (src/index.js:2:646)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (node_modules/this/src/index.js:7:52)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
› Object.<anonymous> (test/cache.js:9:26)
› Module.replacementCompile (node_modules/append-transform/index.js:60:13)
› node_modules/append-transform/index.js:64:4
› Object.<anonymous> (node_modules/append-transform/index.js:64:4)
✖ test/cache.js exited with a non-zero exit code: 1
─
3 uncaught exceptions
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 6.92 | 0 | 0 | 7.03 |
index.js | 6.92 | 0 | 0 | 7.03 | 12-269
----------|---------|----------|---------|---------|-------------------
Feature request from sindresorhus/got#1158.
I noticed that the request cache is storing the compressed body. This adds extra computational load when using the cache - we're decompressing it every time.
Is there any way that the cache could store the decompressed body to avoid this?
Related: sindresorhus/got#392
When the request function throws (as opposed to emitting an error) it causes cacheable-request
to emit an error. This is misleading because errors emitted by cacheable-request
are assumed to be caused by a cache error, request errors are handled by listening for the error event on the request object.
However, we can't attach an event listener to the request object in this scenario because the request object wont exist if the request function throws.
We need a clearer way to handle this error.
Can you please refine the interface or add a new one to return the instance itself instead of a 'request' function. More control is needed in some cases.
Branch | Build failing 🚨 |
---|---|
Dependency | xo |
Current Version | 0.21.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
xo is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
fixture{-*,}.{js,jsx}
fixture{s,}/**
{test,tests,spec,__tests__}/fixture{s,}/**
**/bundle.js
nodeVersion
option set in an override
block. 98dee9a--space
option parsing. f76c901no-misleading-character-class
require-atomic-updates
no-async-promise-executor
ava/no-import-test-file
The new version differs by 10 commits.
be8c1d1
0.22.0
142744a
Bump dependencies
8e4f435
Remove **/bundle.js
as default ignore
f76c901
Fix CLI's --space
option parsing (#342)
98dee9a
Respect nodeVersion
option set in override
block (#345)
e783704
Update dependencies and fix unit tests (#344)
404d81b
Fix links in documentation (#343)
71d06a0
Upgrade to ESLint 5 (#333)
00d6b7c
Don't ignore fixture directories by default (#317)
957b0d9
Add support for TypeScript and document usage with Flow (#326)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Describe the bug
When using [email protected]
in my TypeScript project, I get the following error when trying to compile it:
maxim@ubuntu:~/google-api-typings-generator$ tsc
node_modules/cacheable-request/dist/types.d.ts:7:35 - error TS7016: Could not find a declaration file for module 'http-cache-semantics'. '/home/maxim/google-api-typings-generator/node_modules/http-cache-semantics/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/http-cache-semantics` if it exists or add a new declaration (.d.ts) file containing `declare module 'http-cache-semantics';`
7 import { CachePolicyObject } from 'http-cache-semantics';
~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in node_modules/cacheable-request/dist/types.d.ts:7
How To Reproduce (best to provide workable code or tests!)
The problem is currently present in this PR: Maxim-Mazurok/google-api-typings-generator#709
git clone -b create-pr-action/chore-npm-dedupe-0 https://github.com/Maxim-Mazurok/google-api-typings-generator
cd google-api-typings-generator
nvm i
npm ci
Getting the following error when trying to use https request
unhandledRejection { RequestError: Protocol "https:" not supported. Expected "http:"
at /Users/rajiv/myprojects/crawler-server/node_modules/cacheable-request/src/index.js:200:23
Please upgrade xo to the latest version of xo. Note that if needed to ignore unicorn/prefer-module
current output that needs to be resolved:
> xo && nyc ava
test/cache.js:1:21
✖ 1:21 Do not use "require". unicorn/prefer-module
✖ 2:13 Do not use "require". unicorn/prefer-module
✖ 3:7 Use named import for module util. unicorn/import-style
✖ 3:14 Do not use "require". unicorn/prefer-module
✖ 4:19 Do not use "require". unicorn/prefer-module
✖ 5:26 Do not use "require". unicorn/prefer-module
✖ 6:15 Do not use "require". unicorn/prefer-module
✖ 7:17 Do not use "require". unicorn/prefer-module
✖ 8:14 Do not use "require". unicorn/prefer-module
✖ 9:26 Do not use "require". unicorn/prefer-module
✖ 10:14 Do not use "require". unicorn/prefer-module
✖ 12:14 Do not use "require". unicorn/prefer-module
✖ 12:53 import/no-unresolved rule is disabled but never reported. eslint-comments/no-unused-disable
✖ 17:39 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 27:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 35:22 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 35:27 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 42:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 42:24 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 48:27 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 48:32 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 62:25 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 62:30 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 73:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 73:23 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 86:33 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 86:38 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 100:47 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 100:52 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 107:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 107:23 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 114:8 Missing trailing comma. comma-dangle
✖ 125:83 Do not access a member directly from an await expression. unicorn/no-await-expression-member
✖ 126:84 Do not access a member directly from an await expression. unicorn/no-await-expression-member
✖ 165:4 Missing trailing comma. comma-dangle
✖ 172:12 Missing trailing comma. comma-dangle
✖ 180:44 Missing trailing comma. comma-dangle
✖ 185:30 Missing trailing comma. comma-dangle
✖ 191:30 Missing trailing comma. comma-dangle
✖ 197:36 Missing trailing comma. comma-dangle
✖ 201:6 Unexpected use of require("url").URL. Use the global variable URL instead. node/prefer-global/url
✖ 202:30 Missing trailing comma. comma-dangle
✖ 208:24 Missing trailing comma. comma-dangle
✖ 216:12 Missing trailing comma. comma-dangle
✖ 218:30 Missing trailing comma. comma-dangle
✖ 225:12 Missing trailing comma. comma-dangle
✖ 227:30 Missing trailing comma. comma-dangle
✖ 234:12 Missing trailing comma. comma-dangle
✖ 236:35 Missing trailing comma. comma-dangle
✖ 241:30 Missing trailing comma. comma-dangle
✖ 248:30 Missing trailing comma. comma-dangle
✖ 250:30 Missing trailing comma. comma-dangle
✖ 256:24 Missing trailing comma. comma-dangle
✖ 263:19 Missing trailing comma. comma-dangle
✖ 265:28 Missing trailing comma. comma-dangle
✖ 272:21 Missing trailing comma. comma-dangle
✖ 274:33 Missing trailing comma. comma-dangle
✖ 281:24 Missing trailing comma. comma-dangle
✖ 283:33 Missing trailing comma. comma-dangle
✖ 288:34 Missing trailing comma. comma-dangle
✖ 293:25 Missing trailing comma. comma-dangle
✖ 300:21 Unexpected use of require("url").URL. Use the global variable URL instead. node/prefer-global/url
✖ 301:20 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 305:23 Missing trailing comma. comma-dangle
✖ 316:9 Missing trailing comma. comma-dangle
✖ 318:3 Assertion message should be a string. ava/assertion-arguments
✖ 327:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 327:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 328:8 The variable optsNoCache should be named optionsNoCache. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 346:3 Expected method shorthand. object-shorthand
✖ 351:35 Missing trailing comma. comma-dangle
✖ 355:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 355:37 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 367:3 Expected method shorthand. object-shorthand
✖ 371:35 Missing trailing comma. comma-dangle
✖ 375:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 375:38 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 387:3 Expected method shorthand. object-shorthand
✖ 391:35 Missing trailing comma. comma-dangle
✖ 395:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 396:6 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 397:15 Missing trailing comma. comma-dangle
✖ 410:3 Expected method shorthand. object-shorthand
✖ 414:35 Missing trailing comma. comma-dangle
✖ 418:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 419:6 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 421:15 Missing trailing comma. comma-dangle
✖ 434:3 Expected method shorthand. object-shorthand
✖ 435:17 Invalid group length in numeric value. unicorn/numeric-separators-style
✖ 438:35 Missing trailing comma. comma-dangle
✖ 442:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 443:6 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 445:11 Invalid group length in numeric value. unicorn/numeric-separators-style
✖ 445:17 Missing trailing comma. comma-dangle
✖ 580:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 580:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 594:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 594:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 602:1 after hook must come before test ava/hooks-order
test/cacheable-request-instance.js:1:22
✖ 1:22 Do not use "require". unicorn/prefer-module
✖ 2:21 Do not use "require". unicorn/prefer-module
✖ 3:25 Do not use "require". unicorn/prefer-module
✖ 4:13 Do not use "require". unicorn/prefer-module
✖ 5:23 Do not use "require". unicorn/prefer-module
✖ 6:14 Do not use "require". unicorn/prefer-module
✖ 6:53 import/no-unresolved rule is disabled but never reported. eslint-comments/no-unused-disable
✖ 7:26 Do not use "require". unicorn/prefer-module
✖ 8:19 Do not use "require". unicorn/prefer-module
✖ 9:26 Do not use "require". unicorn/prefer-module
✖ 15:14 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 15:19 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 19:15 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 19:20 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 29:39 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 29:87 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 39:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 43:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 52:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 57:23 Unexpected use of require("url").URL. Use the global variable URL instead. node/prefer-global/url
✖ 61:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 66:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 66:51 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 77:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 78:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 88:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 88:29 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 93:20 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 99:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 104:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 105:16 The variable err should be named error. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 110:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 114:8 The variable errMessage should be named errorMessage. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 117:3 Expected method shorthand. object-shorthand
✖ 121:35 Missing trailing comma. comma-dangle
✖ 124:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 125:16 The variable err should be named error. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 130:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 134:8 The variable errMessage should be named errorMessage. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 138:3 Expected method shorthand. object-shorthand
✖ 141:35 Missing trailing comma. comma-dangle
✖ 144:19 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 145:16 The variable err should be named error. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 150:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 154:8 The variable errMessage should be named errorMessage. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 159:3 Expected method shorthand. object-shorthand
✖ 161:4 Missing trailing comma. comma-dangle
✖ 168:15 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 168:20 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 179:25 The variable err should be named error. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 185:21 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 187:20 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 193:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 193:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 196:16 The variable err should be named error. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 200:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 205:2 Definition for rule promise/prefer-await-to-then was not found. promise/prefer-await-to-then
✖ 207:26 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 207:31 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 215:9 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 215:16 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 218:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 232:23 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 241:2 Definition for rule promise/prefer-await-to-then was not found. promise/prefer-await-to-then
✖ 243:28 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 243:33 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 252:9 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 252:16 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 255:19 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 267:23 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 276:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 276:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 278:25 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 283:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 289:3 Expected method shorthand. object-shorthand
✖ 292:3 Expected method shorthand. object-shorthand
✖ 295:3 Expected method shorthand. object-shorthand
✖ 297:4 Missing trailing comma. comma-dangle
✖ 302:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 302:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 304:25 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 309:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 318:14 Missing trailing comma. comma-dangle
✖ 321:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 321:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 324:25 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 329:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 338:14 Missing trailing comma. comma-dangle
✖ 341:8 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 341:15 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 344:25 Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 349:18 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 353:1 after hook must come before test ava/hooks-order
src/index.js:1:1
✖ 1:1 Do not use "use strict" directive. unicorn/prefer-module
✖ 3:22 Do not use "require". unicorn/prefer-module
✖ 4:16 Do not use "require". unicorn/prefer-module
✖ 5:16 Do not use "require". unicorn/prefer-module
✖ 6:22 Do not use "require". unicorn/prefer-module
✖ 7:22 Do not use "require". unicorn/prefer-module
✖ 8:19 Do not use "require". unicorn/prefer-module
✖ 9:21 Do not use "require". unicorn/prefer-module
✖ 10:18 Do not use "require". unicorn/prefer-module
✖ 11:23 Do not use "require". unicorn/prefer-module
✖ 12:23 Do not use "require". unicorn/prefer-module
✖ 13:14 Do not use "require". unicorn/prefer-module
✖ 27:35 Missing trailing comma. comma-dangle
✖ 31:3 Unexpected return statement in constructor. no-constructor-return
✖ 35:11 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 38:30 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 40:31 Unexpected use of require("url").URL. Use the global variable URL instead. node/prefer-global/url
✖ 41:30 url.parse was deprecated since v11.0.0. Use url.URL constructor instead. node/no-deprecated-api
✖ 45:43 ? should be placed at the beginning of the line. operator-linebreak
✖ 46:34 : should be placed at the beginning of the line. operator-linebreak
✖ 58:38 Missing trailing comma. comma-dangle
✖ 69:32 Missing trailing comma. comma-dangle
✖ 70:6 Missing trailing comma. comma-dangle
✖ 77:46 Use .includes(), rather than .indexOf(), when checking for existence. unicorn/prefer-includes
✖ 91:24 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 132:33 Return values from promise executor functions cannot be read. no-promise-executor-return
✖ 132:63 Missing trailing comma. comma-dangle
✖ 141:14 Missing trailing comma. comma-dangle
✖ 171:12 The variable req should be named request_. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 181:23 The variable opts should be named options. A more descriptive name will do too. unicorn/prevent-abbreviations
✖ 249:21 Missing trailing comma. comma-dangle
✖ 269:1 Do not use "module". unicorn/prefer-module
test/cacheable-request-class.js:1:21
✖ 1:21 Do not use "require". unicorn/prefer-module
✖ 2:14 Do not use "require". unicorn/prefer-module
✖ 2:53 import/no-unresolved rule is disabled but never reported. eslint-comments/no-unused-disable
✖ 3:14 Do not use "require". unicorn/prefer-module
✖ 4:26 Do not use "require". unicorn/prefer-module
229 errors
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
const https = require('https');
const CacheableRequest = require('cacheable-request');
const cacheableRequest = new CacheableRequest(https.request);
const cacheReq = cacheableRequest('https://unpkg.com/[email protected]/dist/vue.js');
cacheReq.on('request', req => {
req.end();
// This is invalid usage!!!
// Instead: cacheableRequest('https://unpkg.com/[email protected]/dist/vue.js', TheResponseCallbackShouldGoHere)
req.on('response', response => {
let x = 0;
// This should be illegal. IOW throw.
response.on('data', chunk => {
x += chunk.length;
console.log(x);
});
});
});
Branch | Build failing 🚨 |
---|---|
Dependency | normalize-url |
Current Version | 3.2.0 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
normalize-url is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
The new version differs by 4 commits.
a03daf0
3.3.0
6078d91
Fix stripWWW
option (#72)
f37cc2c
Rename some options (backwards-compatible) and add new defaultProtocol
option (#71)
55061d2
Add Coveralls
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Solved the issue on the Got side via sindresorhus/got@2abacff#diff-8eef38c70c64f535c3b8046b5ce40d9eR772-R779
Gatsby has a file downloading API. We're looking at making the cache smarter (we only look at etag
s right now) gatsbyjs/gatsby#31408 to avoid making any request if the remote asset set e.g. cache-control headers.
What we're trying to figure out with Got/cachable-request is if it's possible to a) handle storing request bodies ourselves (we need the actual file written to disk) and b) skip the request altogether if the cache is still valid (it seems Got would still try to stream the request body regardless?).
It might be we need to go down another layer and implement this ourselves with http-cache-semantics (which is fine) but we're curious first if this is solvable with vanilla got/cachable-request.
Thanks for all your great work on these libraries!
It would be nice to support the 'stale-if-error' header.
I have created a PR to http-cache-semantics here: kornelski/http-cache-semantics#30
The change is compatible with the code in its current form, I am going to add a PR with the update and a test case.
For sindresorhus/got#827 we need the remoteAddress in the cache. This would require (as I understand correctly) connection: { remoteAddress: response.connection.remoteAddress }
in the following lines:
https://github.com/lukechilds/cacheable-request/blob/d50e6af350b6f52814c71ce3908e704a3d5f428e/src/index.js#L119-L124
And a connection parameter in https://github.com/lukechilds/responselike/blob/093a21bc25ecc82daf17f436c13fd807e5d8eee0/src/index.js#L7
Is this a conceivable change?
How do I manually set cache expiry? I’m caching lots of images that I don’t need after 15 minutes, since I’m caching thousands of images (each of them are between 500-800kB), I would like to release RAM after certain minute!
https://github.com/jaredwray/cacheable-request/blob/main/src/types.ts
You cannot use namespace
. Use named exports instead of nesting in a namespace.
I don't have time to work on this, but if you mention me on a pull request, I'm happy to review it to ensure everything is correct.
The version on npm is 6.0.1
I am using got for querying some data on my website. There will be new data every seconds. So, does using cacheable request speed it up?
I couldn't find any tests for this, but it is very useful for programmatic requests against immutable resources. See https://www.keycdn.com/blog/cache-control-immutable
I am thinking to migrate this library to test with https://jestjs.io/. In my personal experience it's faster, nicely maintained (by facebook) and more feature rich. Ava has many problems like if you try to run tests for v6.0 on Node 10, the process gets stuck without any explanations.
Let me know your thoughts.
Branch | Build failing 🚨 |
---|---|
Dependency |
create-test-server
|
Current Version | 2.1.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
create-test-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 9 commits.
47ef15d
2.2.0
49e21c5
Don't use package-lock.json
23319da
Accept multiple middlewares in app.get
(#16)
5788767
Support returning body without wrapping it in a function (#15)
03dcb00
Enable returning body directly (#14)
107b58e
Update ava to the latest version 🚀 (#10)
4619bf4
Update ava to the latest version 🚀 (#9)
a82d280
Update got to the latest version 🚀 (#8)
0ec211e
Update ava to the latest version 🚀 (#7)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I would like to see functionality that lets cacheable-request
and its downstream parent got
package always revalidate cached results, regardless of the headers received. e.g. if a max-age=300
was received, ignore that and revalidate the result even if queried within the following 5 minutes. Based on a quick reading of the spec, I think this is is like forcing Cache-Control: no-cache
.
Hi!
First : Very good project!!
Can you add an option to not serialize the cache value by default? My cache file is like it:
{
"entries": [
{
"key": "cacheable-request:GET:http://[My url]",
"content": "{\"value\":{\"cachePolicy\":{\"v\":1,\"t\":1636958507292,\"sh\":true,\"ch\":0.1,\"imm\":86400000,\"st\":200,\"resh\":{\"date\":\"Mon, 15 Nov 2021 06:41:47 GMT\",\"server\":\"Apache-Coyote/1.1\",\"x-frame-options\":\"SAMEORIGIN, SAMEORIGIN\",\"cache-control\":\"no-cache, max-age=0\",\"content-type\":\"application/json;charset=UTF-8\",\"vary\":\"Accept-Encoding,Origin\",\"connection\":\"close\",\"transfer-encoding\":\"chunked\"},\"rescc\":{\"no-cache\":true,\"max-age\":\"0\"},\"m\":\"GET\",\"a\":true,\"reqh\":{\"key\":\"-- my internal headers --\"},\"reqcc\":{}},\"url\":\"\",\"statusCode\":200,\"body\":\":base64:[the base 64 content]\"}}"
}
]
}
The content is the value when the lib call "cache.set(key, value)". We can see two things :
It will be very perfect if (1) and (2) can be bypassed. I want to see the content of cache with simple text editor for debug. I can do it before store the value, but i'm afraid to create a bug in the future if API is updated.
Regards.
Describe the bug
When I tried to run the test with npm test
, it fails to pass all tests.
FAIL test/cache.test.ts
● Test suite failed to run
test/cache.test.ts:586:3 - error TS2554: Expected 0 arguments, but got 1.
586 `SELECT * FROM keyv WHERE "key" = "cacheable-request:GET:${
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
587 s.url + endpoint
~~~~~~~~~~~~~~~~~~~
588 }"`,
~~~~~
test/cache.test.ts:592:9 - error TS2571: Object is of type 'unknown'.
592 expect(cacheResult.length).toBe(1);
~~~~~~~~~~~
test/cache.test.ts:593:14 - error TS2554: Expected 0 arguments, but got 1.
593 await query('DELETE FROM keyv');
~~~~~~~~~~~~~~~~~~
To Reproduce
npm test
Expected behavior
All tests pass.
When running the example code with a redis cache, the javascript code won’t exit
Code used:
const CacheableRequest = require('cacheable-request');
const http = require('http');
// You can do
const cacheableRequest = new CacheableRequest(http.request, 'redis://localhost:6379');
const cacheReq = cacheableRequest('http://ruben.verborgh.org', res => {
//Do nothing
});
cacheReq.on('request', req => req.end());
When running
const CacheableRequest = require('cacheable-request');
const http = require('http');
// You can do
const cacheableRequest = new CacheableRequest(http.request, new Map());
const cacheReq = cacheableRequest('http://ruben.verborgh.org', res => {
//Do nothing
});
cacheReq.on('request', req => req.end());
NodeJS exits normally
This library source code resides in single javascript file and has almost no comments. It can become hard to maintain in future. The code needs to be divided in smaller modules.
Currently hooks are stored in a global context and affect all instances. Also the types have any
which is incorrect.
with got 8.2.0
got.stream(imgUrl, { cache: keyv }).pipe(res);
records in mongodb:
{ "_id": ObjectID("5ab084465a793ecc436a7849"), "key": "cacheable-request:GET:https://farm2.staticflickr.com/1521/26180297656_675e75a2ce_h.jpg", "value": "{\"value\":{\"cachePolicy\":{\"v\":1,\"t\":1521635364661,\"sh\":true,\"ch\":0.1,\"imm\":86400000,\"st\":200,\"resh\":{\"date\":\"Wed, 21 Mar 2018 12:29:24 GMT\",\"connection\":\"close\",\"expires\":\"Wed, 28 Mar 2018 12:29:24 UTC\",\"cache-control\":\"max-age=604800,public\",\"via\":\"http/1.1 pc-pool116.flickr.gq1.yahoo.com (ApacheTrafficServer [cMsSfW])\",\"server\":\"ATS\",\"x-photo-farm\":\"2\",\"x-photo-farm-guess\":\"2\",\"access-control-allow-origin\":\"*\",\"access-control-allow-methods\":\"POST, GET, OPTIONS\"},\"rescc\":{\"max-age\":\"604800\",\"public\":true},\"m\":\"GET\",\"a\":true,\"reqh\":null,\"reqcc\":{}},\"url\":\"\",\"statusCode\":304,\"body\":\":base64:\"},\"expires\":null}", "expiresAt": null }
Currently we are running a very old version of Ava. Please upgrade and fix all tests to make sure they work on Nodejs version 12, 14, and 16.
Is this library meant as a private or a shared cache?
If shared, is there a straight forward way to be using this library in cooperation with a shared cache like a reverse proxy?
https://github.com/nodejitsu/node-http-proxy
Disclaimer: I'm fairly new to Node :)
The following event listener in CacheableRequest.js is never removed:
this.cache.on('error', err => ee.emit('error', new CacheableRequest.CacheError(err)));
These listeners will keep accumulating in the scenario where you are reusing a single CacheableRequest to service multiple requests (which I believe is the intention?).
Moreover, the error produced by the cache is not necessarily associated with the current request - it's a generic error that is broadcast to all listeners.
IssueHunt has been backed by the following sponsors. Become a sponsor
Branch | Build failing 🚨 |
---|---|
Dependency | delay |
Current Version | 3.0.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
delay is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | create-test-server |
Current Version | 2.0.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
create-test-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 6 commits.
db97c92
2.1.0
ab99182
Update tests to check new port exports
b21c3a0
Export port and SSL port
7e0d18e
Update coveralls to the latest version 🚀 (#6)
7e6b4b6
Update ava to the latest version 🚀 (#5)
a6cdf3a
chore(package): update ava to version 0.21.0 (#4)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Currently we support node 12 but when looking to move to Nodejs 14 the following error happens:
➜ cacheable-request git:(master) npm test
> [email protected] test /Users/jaredwray/src/github.com/jaredwray/cacheable-request
> xo && nyc ava
59 tests passed
1 unhandled rejection
Unhandled rejection in test/cacheable-request-instance.js
/Users/jaredwray/src/github.com/jaredwray/cacheable-request/node_modules/end-of-stream/index.js:53
Error: premature close
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
index.js | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------
npm ERR! Test failed. See above for more details.
To replicate this do the following:
master
nvm use 14
npm i
npm test
This should not have any errors in it.
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.
Since we did not receive a CI status on the greenkeeper/initial
branch, we assume that you still need to configure it.
If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/
.
We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
Seems that status code is ignored because github.com/kornelski/http-cache-semantics is waiting for status not for statusCode. Should we rename it in this line
https://github.com/lukechilds/cacheable-request/blob/130fcbe79b9b7427b1d8016756be85aa3d52a303/src/index.js#L95
as it's done on https://github.com/lukechilds/cacheable-request/blob/130fcbe79b9b7427b1d8016756be85aa3d52a303/src/index.js#L85?
Supporting method has been implemented on the http-cache-semantic library.
I'm using https://github.com/sindresorhus/got and cache was not working as expected, while debugging i found this issue.
In https://github.com/lukechilds/cacheable-request/blob/master/src/index.js#L139
policy.satisfiesWithoutRevalidation
expects a response object. But instead of a response, opts is passed.
policy.satisfiesWithoutRevalidation
source https://github.com/kornelski/http-cache-semantics/blob/master/index.js#L137
I'm trying to use got
to cache my authenticated github requests.
Github API returns Cache-Control: private
header for authenticated requests, so http-cache-semantics
without shared: false
option determines the response as not cacheable.
I'd like to find a way to pass shared: false
configuration all the way got > cacheable-request > http-cache-semantics
. Any ideas how?
UPD: By reading source code in all 3 libraries I figured that I can just pass shared: false
in got options (despite typescript forbidding it) and it goes all the way to http-cache-semantics
. But unfortunately it doesn't solve my problem of authenticated github requests being not cached. Digging further...
Please let users set options for http-cache-semantics. I am especially interested in shared: false
option.
https://github.com/kornelski/http-cache-semantics#constructor-options
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.