如何建立既httpexpires和cachecontrol头 [英] how to set up both httpexpires and cachecontrol headers
问题描述
我要建立在网络都失效和
cachecontrol
和 httpExpires
头。配置
通过对这个问题下面的答案
<一href=\"http://stackoverflow.com/questions/5946894/whats-the-difference-expires-and-cache-controlmax-age\">What's区别过期和缓存控制:最大年龄
I want to set up both expires and cachecontrol
and httpExpires
headers in web.config
by following the answer on that question
What's the difference Expires and Cache-control:max-age?
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
<clientCache cacheControlCustom="public" httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" cacheControlMode="UseExpires" />
</staticContent>
</system.webServer>
但出于某种原因图像变得不,当我这样做用。
But for some reason images became not available when I am doing that.
我已经有了无法加载资源:服务器在每个图像负荷500(内部服务器错误)
错误的状态回应(我可以看到,在错误浏览器开发工具的控制台
)。
I've got Failed to load resource: the server responded with a status of 500 (Internal Server Error)
error on each image load (I can see that errors in browser dev tools console
).
我想我配置错了?
这将通过剩下的只有单一的一个,如果我评论的任何 clientCache
的工作节
It would work if I comment any of clientCache
section by leaving only single one
如何解决?
更新:
刚才问多了一个相关的问题<一href=\"http://stackoverflow.com/questions/20831122/how-to-set-up-both-httpexpires-and-cachecontrol-headers-web-cofig\">how建立既httpexpires和cachecontrol头web.cofig :
推荐答案
这<一个href=\"http://stackoverflow.com/questions/20826035/how-to-set-up-both-httpexpires-and-cachecontrol-headers\">IIS客户端缓存页面指出,虽然过期和max-age的设置偏于analagous,最大年龄指令优先于过期。然而,当一个max-age的clientCache条目并行使用与IIS生成HTTP 500错误过期clientCache条目。
This IIS Client Cache page states that 'While the "Expires" and "max-age" settings are somewhat analagous, the "max-age" directive takes priority over "Expires"'. However, IIS generates HTTP 500 errors when one "max-age" clientCache entry was used in parallel with an "Expires" clientCache entry.
在过期,并在IIS调整设置常用标题当最大年龄是相互排斥彼此。您可以使用一个或另一个,但不能两者兼得。
The "Expires" and "max-age" are mutually exclusive of one another when adjusting the "Set Common Headers" in IIS. You can use one or the other, but not both.
其他高速缓存指令可应用于Web.config中的子文件夹或特定文件。看到这个<一个href=\"http://stackoverflow.com/questions/2195266/how-to-configure-static-content-cache-per-folder-and-extension-in-iis7\">stackoverflow在IIS7配置缓存中的内容页面。
Other cache directives can be applied to subfolders or specific files in Web.config. See this stackoverflow page on configuring cache content in IIS7.
这篇关于如何建立既httpexpires和cachecontrol头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!