且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

过期输出缓存 ASP.Net MVC

更新时间:2023-02-25 19:19:02

小心使用None"与".

Be careful about using "None" vs. "".

  • 如果您发送",则 变化 发送.
  • 如果您发送无",则 变化 发送.
  • If you send "" then the HttpHeader for Vary is not sent.
  • If you send "None" then the HttpHeader for Vary is sent.

我使用 Fiddler 来验证这种行为.

I used Fiddler to verify this behavior.

这似乎会影响浏览器是否会返回服务器检查最新版本(导致 304).至少在 Chrome 中是这样.如果您确定不想在文件过期之前更新文件,您想使用 Varies="".

This seems to have an impact on whether or not the browser goes back to the server to check for latest version (causing a 304). At least in Chrome it does. You want to use Varies="" if you know for sure you aren't going to want to update the file before it has expired.

我建议使用 Varies="",就像我在 这篇文章.对于我的 javascript 文件,我不希望浏览器返回并发出另一个 Http 请求,直到它过期.304 是不必要的.

I'd recommend using Varies="" as I did in this post. For my javascript file I dont want the browser going back and making another Http request until it has expired. 304 is unnecessary.