Please check the cache-control headers for the static files to see whether this http header is added to the response expected and cache settings in the browser to see if the cache is disabled. If the browser doesn't follow the http cache headers, it is recommend that submit the issue for that specific browsers.
ASP.NET Core Run Middleware behave differently with different browser.
Below is my middleware code:
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
"public,max-age=10"; // Here I placed my first breakpoint
}
});
app.Run(async context =>
{
await context.Response.WriteAsync("<html><body><a href='images/image1.jpg' target='_blank'>Click for Image1</a></body></html>"); // Here is my Second Breakpoint
});
I placed a break point within Run Middleware as well as with in UseStaticFiles Middleware.
I just cached the static files for 10 seconds.
Then I click on Anchor tag created with in my run middle ware from browser. When I hit this anchor tag from chrome. First time it hit both the break point and rightly so. From next time onward, it only hit Second break point. If it is cached then it should not hit our application. And cache is working that's why UseStaticFiles is not hit.
But when I hit via Firefox. From second request onward it never hit our Run Middleware. Even after cache duration is over. After 10 second it hit UseStaticFiles but not RUN middleware.
What is happening. Any idea?