Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding caching behaviour (cache even if remote host told me to not do that) #746

Open
1 task done
bago opened this issue Mar 8, 2019 · 4 comments
Open
1 task done
Labels
💵 Funded on Issuehunt The issue has been funded on Issuehunt enhancement This change will extend Got features external The issue related to an external project

Comments

@bago
Copy link

bago commented Mar 8, 2019

Issuehunt badges

What would you like to discuss?

I'd like to override got caching so to extend what the remote headers ask me to do.
I currently use the max-stale in the request header to extend somehow the caching, but this doesn't work if the remote service use strict caching headers and got doesn't even store them.

I tried manipulating response headers in the .on('response', ) hook, but this doesn't work. Sounds like got caches the manipulated response, but the cachecontrol is precomputed into a different property and uses the original cache-control.

I guess this is something happending in cacheable-request makeRequest's response handler that calls the ee.emit('response') AFTER storing the response, so maybe I should open an issue against the "cacheable-request" project, but my knowledge of got internals is very limited, so I preferred to start with this question as maybe you can identify a better way or a workaround to alter if and how long got caches a result.

Checklist

  • I have read the documentation.

There is a $60.00 open bounty on this issue. Add more on Issuehunt.

@szmarczak szmarczak added enhancement This change will extend Got features external The issue related to an external project labels Mar 12, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $60.00 to this issue.


@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt The issue has been funded on Issuehunt label May 10, 2019
@rifler
Copy link
Contributor

rifler commented May 23, 2019

my use case:
I want to cache every outgoing GET request within current incoming request.
I create express middleware

function cacheHttpAdapter(req: Request, res: Response, next: NextFunction) {
    req.cacheHttpAdapter = new Map();

    next();
}

and pass it to got wrapper, similar to described in #723 , because I don't want RFC cache behaviour

It will be much more convenient to manage cache behaviour without any wrappers

@szmarczak
Copy link
Collaborator

@sindresorhus can we close this one and move to #875 ?

@sindresorhus
Copy link
Owner

Let's keep it open so we can use the bounty for this issue for #875 instead. We can close this issue when #875 is closed. I'll lock it instead.

Repository owner locked and limited conversation to collaborators Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💵 Funded on Issuehunt The issue has been funded on Issuehunt enhancement This change will extend Got features external The issue related to an external project
Projects
None yet
Development

No branches or pull requests

5 participants