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?