asp.net-mvc – 缓存CSS和JS文件

当我在不到2-3分钟内刷新我的网站时,Firebug显示了这些不错的请求:
1. /core.css          304 Not modified
2. /core.js           304 Not modified
3. /background.jpg    304 Not modified

但是当我刷新3分钟后,我得到:

1. /core.css          200 OK
2. /core.js           200 OK
3. /background.jpg    304 Not modified

为什么我的CSS和JS文件被再次下载和图像不是?

我使用ASP.NET MVC 3,我不使用[OutputCache],在我的/ Content文件夹(其中所有css,js和img文件存在于子文件夹中)我有这个Web.config

<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>

它设置HTTP头缓存控制:max-age = 86400 ONLY。所以基本上CSS,JS和图像都是以同样的方式对待的,但是不管怎样,CSS和JS不会被缓存一段较长的时间?为什么呢?

解决方法

希望这将有助于: http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache

The <clientCache> element of the 07001 element specifies cache-related HTTP headers that IIS 7 and later sends to Web clients,which control how Web clients and proxy servers will cache the content that IIS 7 and later returns…

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....