Comments (4)
Btw, I have actually been meaning to build a reverse proxy backed by cacheable-request
but haven't had the time to put into it yet.
Let me know if you build it, I'd love to link to it in the readme.
from cacheable.
It is suitable to be used a shared cache, private
is not cacheable and s-maxage
is respected.
I don't think nodejitsu/node-http-proxy supports passing in a request function so not with that lib directly but I'm sure there are others that do. If not it wouldn't be too simple to write your own, for example see:
https://github.com/lukechilds/pirateproxy (Got uses cacheable-request
under the hood)
from cacheable.
My understanding is that there are two types of cache, shared and private (called user agent cache or single user cache)
https://github.com/kornelski/http-cache-semantics#constructor-options
If options.shared is true (default), then the response is evaluated from a perspective of a shared cache (i.e. private is not cacheable and s-maxage is respected). If options.shared is false, then the response is evaluated from a perspective of a single-user cache (i.e. private is cacheable and s-maxage is ignored).
And MDN:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Cacheability
private
Indicates that the response is intended for a single user and must not be stored by a shared cache. A private cache may store the response.
Anyway by diving into this library code, I can see that it is using the default options of http-cache-semantics which has shared cache set to true. So it will not cache any response that have cache-control: private
It would be nice if we could set all or some of the cachepolicy options ourselves. I am implementing a user agent and would benefit from caching responses with cache-control: private
PR wanted?
from cacheable.
Sorry, just seen this, yeah definitely, it should be very simple to change.
For example:
response.cachePolicy = new CachePolicy(opts, response);
Just needs to be:
response.cachePolicy = new CachePolicy(opts, response, opts.cachePolicy);
(or similar)
And then you have full control over the CachePolicy
options.
from cacheable.
Related Issues (20)
- Upgrading xo package to ^0.49.0
- Migrating to Typescript
- Make proper changelogs HOT 1
- Hooks should be per-instance HOT 3
- Fail to run the test HOT 3
- Types needs to be updated for ESM HOT 2
- Cannot use namespace 'ResponseLike' as a type. HOT 18
- Could not find a declaration file for module 'http-cache-semantics' HOT 2
- [regression] Could not find a declaration file for module 'http-cache-semantics' HOT 3
- Memory leak HOT 4
- [question] security fix for http-cache-semantics 4.1.1 in v8 HOT 13
- memory leak in got@11 HOT 14
- Regular Expression Denial of Service (ReDoS) Vulnerability Found in a Package
- 7.0.3 Deployment now expects Node Version > 14, breaking change. HOT 9
- Nodejs version 20 creates error with Request
- [email protected] requires Node.js >= 16 HOT 4
- Sourcemaps point to missing source files HOT 2
- When upgrading to latest get-stream it is no longer compatible with nodejs 16
- LICENSE text (MIT) missing in npm module HOT 1
- Thoughts on using standardized web Request / Response / Headers? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacheable.