我已经在MVC4中使用了bundling
来管理css
和js
文件,但是我没有找到用于管理/缓存图像和MVC4中的媒体文件的好解决方案。
我应该为此运行另一台静态文件服务器吗?
您可以通过web.config和staticContent/clientCache
元素为静态内容配置IIS CACHE标头。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="01:00:00" />
</staticContent>
</system.webServer>
</configuration>
用于一个小时的缓存策略。