MVC RC“文件” ActionResult,表现好吗? [英] MVC RC "File" ActionResult, performant?

查看:109
本文介绍了MVC RC“文件” ActionResult,表现好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新的FileActionResult,我正在考虑创建一个控制器来在我的ASP.NET MVC应用程序中显示某些图像。

With the new "File" ActionResult, I was thinking about creating a controller to display certain images in my ASP.NET MVC app.

类似于:

<img src="/Photo/Show/hello" alt="Hello" title="Hello" />

vs:

<img src="/Photo/Folder/Hello.jpg" alt="Hello" title="Hello" />

我很好奇性能影响是什么。假设我什么也没做,只是从控制器返回图像文件,从控制器动作调用图像与仅将路径编码到src属性中是否存在明显的性能差异?

I'm curious as to what the performance impact would be. Assuming I did nothing but return the image file from the controller, is there a noticeable performance difference in calling the image from a controller action versus just coding the path into the src attribute?

推荐答案

小但可衡量的性能影响确定无疑。但是,在它变得高度相关之前,性能完全无关。因此,除非您的服务器屈服或者您的用户必须等待他们的页面加载,并且您需要开始缓解,所以不要担心性能。

Small but measurable performance impact to be sure. However, performance is totally irrelevant until it becomes highly relevant. So unless your server is buckling or your users have to wait for their pages to load, and you need to start mitigating, don't worry about the performance.

DO 担心以下问题:您需要在服务器上重新实施缓存策略,因为IIS管理直接请求的静态文件。您还需要确保使用响应中包含的正确标头管理客户端缓存。最后,问问自己是否重新发明一种从服务器提供静态文件的方法是满足您应用程序需求的。

DO worry about the following: you will need to re-implement a caching strategy on the server, since IIS manages that for static files requested directly. You will also need to make sure you manage your client-side caching with the correct headers included in the response. Ultimately, just ask yourself if re-inventing a method of serving static files from a server is something that serves your application's needs.

这篇关于MVC RC“文件” ActionResult,表现好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆