Ali*_*ned 4 asp.net kestrel-http-server asp.net-core
我使用Asp.Net Core RC2和Kestrel作为我的Web服务器.我需要确保使用no-cache标头响应请求(在这种情况下所有这些请求),以便浏览器获得最新版本(而不是304).
在Startup中有没有办法配置Kestrel或将此步骤注入管道?
编辑:在我的情况下,no-store可能是更好的选择:https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching "no-store不允许缓存响应并且必须在每次请求时全部取出."
您可以使用中间件来处理标头.例如,您可以通过将以下内容添加到Startup的Configure方法的顶部来强制执行no-cache缓存控制:
app.Use(async (httpContext, next) =>
{
httpContext.Response.Headers[HeaderNames.CacheControl] = "no-cache";
await next();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1621 次 |
| 最近记录: |