*Where* to set caching headers for HTML responses in ASP.NET MVC?

眉间皱痕 提交于 2019-12-10 12:16:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!