Expire Output Cache ASP.Net MVC

前端 未结 4 1898
走了就别回头了
走了就别回头了 2020-12-07 18:05

I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cac

4条回答
  •  情歌与酒
    2020-12-07 18:48

    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.

    I used Fiddler to verify this behavior.

    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.

    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.

提交回复
热议问题