Skip to content

[Enhancement] Disable Cache for request #18

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

Open
ThaDaVos opened this issue Jul 3, 2024 · 3 comments
Open

[Enhancement] Disable Cache for request #18

ThaDaVos opened this issue Jul 3, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ThaDaVos
Copy link
Contributor

ThaDaVos commented Jul 3, 2024

Summary

Please provide a brief summary of your proposal. Two to three sentences is best here.

The option to disable the caching for a request - preferably using HttpRequestMessage.Options.Set() to set a value on the HttpRequestMessage which disables caching for a single request/response.

Why? Cause you can't change handlers after the Client is initiated and I don't want to create multiple HttpClients for this.

API Changes

Include a list of all API changes, additions, subtractions as would be required by your proposal.

e.g.

In order for this to work - the IF statement which checks if it's inside the cache also needs to check HttpRequestMessage.Options if the option to skip cache has been set

if (request.Method == HttpMethod.Get || request.Method == HttpMethod.Head)

public readonly HttpRequestOptionsKey<bool> UseCache = new("UseCache");

....

// Inside SendAsync and Send

if (!(request.Options.TryGetValue(UseCache, out bool useCache) && useCache) && (request.Method == HttpMethod.Get || request.Method == HttpMethod.Head))

Intended Use Case

Provide a detailed example of where your proposal would be used and for what purpose.

It can be used to force up date the cache depending if the above IF change is also included in the IF statement for storing the response - second it can be used to skip the cache all together when needed.

@ThaDaVos ThaDaVos added the enhancement New feature or request label Jul 3, 2024
@thomasgalliker
Copy link
Owner

Cool idea @ThaDaVos
I gonna have to put some thinking into it.
Aren‘t there also cache headers in http requests which could be used for this purpose?

@ThaDaVos
Copy link
Contributor Author

ThaDaVos commented Jul 7, 2024

Already got stuff done on a fork - will create a pull-request later so you can check

@ThaDaVos
Copy link
Contributor Author

See: #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants