dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.59k stars 10.06k forks source link

Response Caching should ignore the host part of the request #43271

Open ronniebarker opened 2 years ago

ronniebarker commented 2 years ago

Ideally, response caching should really only take notice from the path onwards (with all the great options for query parameters and headers of course) sine http://mydomain.com/images/logo.png and https://mydomain.com/images/logo.png and http://192.168.1.1/images/logo.png and https://www.mydomain.com/images/logo.png should be the same resource (since they are actually the same file) and only cache once (and when one is replaced, so should all the others).

So I thought maybe I could just register a new IResponseCachingKeyProvider that provided a different implementation of the key, but all the interfaces are internal - so much of open for extensibility :-(

sebastienros commented 2 years ago

Same response as here but the key provider is also not public. There is a CacheKey property on the OutputCacheContext, but I will need to check if it can be set by custom policies still.

sebastienros commented 2 years ago

I checked and the CacheKey is also internal. We'll use this feedback to discuss if the interface should be public.

adityamandaleeka commented 2 years ago

Triage: we'll consider making this public in 8 based on demand.

sebastienros commented 2 years ago

7.0 RC2 Output Caching will have SetVaryByHost(bool)

ronniebarker commented 2 years ago

That's great!

On Tue, Sep 13, 2022 at 19:24:24, Sébastien Ros @.***> wrote:

7.0 RC2 Output Caching will have SetVaryByHost(bool)

— Reply to this email directly, view it on GitHub https://github.com/dotnet/aspnetcore/issues/43271#issuecomment-1245795998, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7RBJRDVIG7TLTTQW7JXDV6DBFRANCNFSM56O6MYZQ . You are receiving this because you authored the thread.Message ID: @.***>