为什么我们需要添加app.useresponsecaching();?

发布于 2025-02-10 03:48:11 字数 654 浏览 1 评论 0原文

在.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶ ̄淡然 2025-02-17 03:48:12

错误是我正在使用不可信的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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文