问题
I want to prevent browsers from caching HTML pages which they unfortunately do by default.
I understand the headers I need to set. But where in my ASP.NET MVC app is the appropriate place to set them?
The controllers do not seem right since that would be repetitive code and controllers can send non-HTML responses as well (e.g. JSON).
BeginRequest
appears too broad since that would affect resources (and anything else I might not realize).
The suggested duplicate does not solve this issue: I only want to affect HTML pages (not the entire site) and the duplicate does not say where to add this code (it says "add where needed").
来源:https://stackoverflow.com/questions/43452789/where-to-set-caching-headers-for-html-responses-in-asp-net-mvc