-
Hello, I'm testing using the new OutputCaching that was introduced in dotnet 7 preview 6 with YARP. Currently doing the following as a test: var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
builder.Services.AddOutputCache(options =>
{
options.DefaultExpirationTimeSpan = TimeSpan.FromHours(1);
});
var app = builder.Build();
app.UseOutputCache();
app.MapReverseProxy().CacheOutput();
app.Run(); This works and the results are cached as expected. However I was considering how I could validate cached content when caching static content for example. Since YARP and OutputCaching are not aware of each other I can't decide where it make sense for this kind of logic to live.. Perhaps there is a way to implement OutputCaching within a custom proxy pipeline and put the validation there? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I can see that OutputCacheMiddleware.cs contains logic for checking the etag/last modified if the request contains "If-Modified-Since" or "If-None-Match" but its just to return a 304 to the client, not to invalidate the cache. Its looking like OutputCaching is not going to be appropriate for content caching with yarp in an edge proxy scenario where the cache needs to be persisted. I've written a disk backed IOutputCacheStore implementation for OutputCaching, but need the ability to invalidate items in the cache other then by time. I see its on the roadmap to have native disk storage for OutputCaching in dotnet 8. Perhaps by then it will be more flexible for this kind of scenario. I'd love to hear anyone else's opinions on this. |
Beta Was this translation helpful? Give feedback.
-
Logged feedback to asp.net core repo dotnet/aspnetcore#43791 |
Beta Was this translation helpful? Give feedback.
-
I'm guessing that this would need to be implemented in the IHttpForwader or a wrapper around it.
So your order of wrapping is wrong - the caching will need to go around the reverse proxy mappings. |
Beta Was this translation helpful? Give feedback.
Logged feedback to asp.net core repo dotnet/aspnetcore#43791