为什么我们需要添加app.useresponsecaching();?
在.asp Net Core中遵循一些缓存教程并进行了一些局部测试后,我有一些疑问:
步骤
我添加了标题
[ResponseCache(VaryByHeader = "User-Agent", Duration = 180)]
HTTP响应具有适当的标题
cache-control: public,max-age=180
< EM> 结论
尽管标题还可以,但在任何浏览器中都不会缓存响应。
问题
我的第一个问题是为什么私人缓存不保存该请求的请求? 使其正常工作的唯一方法是在启动中配置:
app.UseResponseCaching();
但是,当我检查它时,它会在API调用中返回API/服务器中的高速缓存存储中的数据。 第二个问题是为什么浏览器需要击中API?
有人可以解释为什么浏览器没有任何封存? (我已经检查了在开发人员工具中是否启用了SI),
非常感谢
after following some cache tutorials in .ASP Net Core, and performed some local tests i have some doubts related:
Steps I did
I added the header
[ResponseCache(VaryByHeader = "User-Agent", Duration = 180)]
Http responses has the proper header
cache-control: public,max-age=180
Conclusion
Despite the headers are OK, the response is never cached in any browser.
Questions
My first question is, why private caches are not saving that request for that request?
The only way to make it working is to configure in the startup :
app.UseResponseCaching();
But as I have checked it results in an API call that return the data from the cache store in the API/server. Second question is why browser needs to hit the API?
Someone can explain why the browsers are no caching anything?
(I have checked that it si enabled in Developer tools)
Many thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误是我正在使用不可信的SSL证书。
发生这种情况时,私人缓存停止工作
在此处查看更多信息: etags并在HTTPS SSL上进行了最后修饰?
The mistake was that I was using a no-trustable SSL certificate.
When that happens, private cache stops working
See more info here: Etags and last-modified over https SSL?