Skip to content

[Enhancement] Disable Cache for request #18

Open
@ThaDaVos

Description

@ThaDaVos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions