I've been reading about the staticContent element in the web.config file but I'm having a bit of trouble figuring out exactly what ASP.Net considers static content. I assume it's going to include images, js files, css and static html files but I can't seem to find any articles that explicitly state this. Does anyone have links to documentation that explains this in detail?
我一直在阅读web.config文件中的staticContent元素,但我在确定ASP.Net究竟认为静态内容时遇到了一些麻烦。我假设它将包括图像,js文件,CSS和静态html文件,但我似乎找不到任何明确说明这一点的文章。有没有人有文档链接详细解释这个?
4 个解决方案
#1
9
I think this may be the information you're missing - Static Content MimeMap
我想这可能是你缺少的信息 - 静态内容MimeMap
#2
1
As I understand it, the staticContent element in the web.config is where you can set how your site should cache it's static resource.
据我所知,web.config中的staticContent元素是您可以设置网站缓存静态资源的方式。
So as to your question of what kind of content can be specified here, it would be any file that you could benefit from caching, i.e. images, video, etc.
至于你在这里可以指定什么类型的内容的问题,它可以是你可以从缓存中受益的任何文件,即图像,视频等。
Also, just to provide some links I found useful:
How to configure static content cache per folder and extension in IIS7?
http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
另外,只是提供一些我认为有用的链接:如何在IIS7中为每个文件夹和扩展配置静态内容缓存? http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
#3
1
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap says,
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap说,
The
<mimeMap>
element of the<staticContent>
element is included in the default installation of IIS 7.
元素的 元素包含在IIS 7的默认安装中。
IOW the list of 'static' file types is I suppose defined in the server's machine.config and/or overriden using web.config files.
IOW我在服务器的machine.config中定义的'静态'文件类型列表和/或使用web.config文件覆盖。
You can select "Mime Types" in IIS Manager to view the list of MIME Types ... I see about 400 of these, from .323
and .aac
through to .xslt
and .zip
, including .htm
and .html
but not including .aspx
.
您可以在IIS管理器中选择“Mime类型”以查看MIME类型列表...我看到其中大约400个,从.323和.aac到.xslt和.zip,包括.htm和.html,但不包括的.aspx。
#4
0
Whilst this question is rather old and I expect Kiquenet got it sorted out none of the answers actually answer the question, I found this article looking for the answer, I expect others will to. This article answers the question:
虽然这个问题相当陈旧,我希望Kiquenet能够解决问题但实际上没有答案回答这个问题,我发现这篇文章正在寻找答案,我希望其他人能够这样做。本文回答了这个问题:
IIS和静态内容?
To paraphrase, static files are those IIS does not have a specific handler for. i.e. every file type listed in the .Net framework web.config section httpHandlers is NOT static.
换言之,静态文件是那些IIS没有特定处理程序的文件。即.Net框架web.config部分httpHandlers中列出的每个文件类型都不是静态的。
Please look at Ben Swayne's most excellent answer, to quote:
请看Ben Swayne最优秀的答案:
You can inspect the list of file handlers in IIS by navigating to your website and then click 'Handler Mappings'. By default these are inherited from the .Net base web.config which is in a different location depending on your .Net framework version.
您可以通过导航到您的网站,然后单击“处理程序映射”来检查IIS中的文件处理程序列表。默认情况下,这些都是从.Net base web.config继承的,它位于不同的位置,具体取决于您的.Net框架版本。
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
C:\ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG \ web.config C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config \ web.config
If a file being requested isn't already explicitly mapped to another handler it falls to a catch all handler (*) as the last option (System.Web.DefaultHttpHandler) which determines if it is a static file or a directory browsing request. So Static files are simply files not bound to another handler already.
如果正在请求的文件尚未显式映射到另一个处理程序,则它将落入catch all handler(*)作为最后一个选项(System.Web.DefaultHttpHandler),该选项确定它是静态文件还是目录浏览请求。所以静态文件只是已经没有绑定到另一个处理程序的文件。
#1
9
I think this may be the information you're missing - Static Content MimeMap
我想这可能是你缺少的信息 - 静态内容MimeMap
#2
1
As I understand it, the staticContent element in the web.config is where you can set how your site should cache it's static resource.
据我所知,web.config中的staticContent元素是您可以设置网站缓存静态资源的方式。
So as to your question of what kind of content can be specified here, it would be any file that you could benefit from caching, i.e. images, video, etc.
至于你在这里可以指定什么类型的内容的问题,它可以是你可以从缓存中受益的任何文件,即图像,视频等。
Also, just to provide some links I found useful:
How to configure static content cache per folder and extension in IIS7?
http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
另外,只是提供一些我认为有用的链接:如何在IIS7中为每个文件夹和扩展配置静态内容缓存? http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
#3
1
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap says,
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap说,
The
<mimeMap>
element of the<staticContent>
element is included in the default installation of IIS 7.
元素的 元素包含在IIS 7的默认安装中。
IOW the list of 'static' file types is I suppose defined in the server's machine.config and/or overriden using web.config files.
IOW我在服务器的machine.config中定义的'静态'文件类型列表和/或使用web.config文件覆盖。
You can select "Mime Types" in IIS Manager to view the list of MIME Types ... I see about 400 of these, from .323
and .aac
through to .xslt
and .zip
, including .htm
and .html
but not including .aspx
.
您可以在IIS管理器中选择“Mime类型”以查看MIME类型列表...我看到其中大约400个,从.323和.aac到.xslt和.zip,包括.htm和.html,但不包括的.aspx。
#4
0
Whilst this question is rather old and I expect Kiquenet got it sorted out none of the answers actually answer the question, I found this article looking for the answer, I expect others will to. This article answers the question:
虽然这个问题相当陈旧,我希望Kiquenet能够解决问题但实际上没有答案回答这个问题,我发现这篇文章正在寻找答案,我希望其他人能够这样做。本文回答了这个问题:
IIS和静态内容?
To paraphrase, static files are those IIS does not have a specific handler for. i.e. every file type listed in the .Net framework web.config section httpHandlers is NOT static.
换言之,静态文件是那些IIS没有特定处理程序的文件。即.Net框架web.config部分httpHandlers中列出的每个文件类型都不是静态的。
Please look at Ben Swayne's most excellent answer, to quote:
请看Ben Swayne最优秀的答案:
You can inspect the list of file handlers in IIS by navigating to your website and then click 'Handler Mappings'. By default these are inherited from the .Net base web.config which is in a different location depending on your .Net framework version.
您可以通过导航到您的网站,然后单击“处理程序映射”来检查IIS中的文件处理程序列表。默认情况下,这些都是从.Net base web.config继承的,它位于不同的位置,具体取决于您的.Net框架版本。
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
C:\ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG \ web.config C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config \ web.config
If a file being requested isn't already explicitly mapped to another handler it falls to a catch all handler (*) as the last option (System.Web.DefaultHttpHandler) which determines if it is a static file or a directory browsing request. So Static files are simply files not bound to another handler already.
如果正在请求的文件尚未显式映射到另一个处理程序,则它将落入catch all handler(*)作为最后一个选项(System.Web.DefaultHttpHandler),该选项确定它是静态文件还是目录浏览请求。所以静态文件只是已经没有绑定到另一个处理程序的文件。