MVC RC "File" ActionResult, performant?

With the new β€œFile” ActionResult, I was thinking of creating a controller to display specific images in my ASP.NET MVC application.

Something like:

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

against

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

I'm curious what the impact of performance will be. Assuming I did nothing but return the image file from the controller, is there a noticeable difference in performance when the image is called from the controller action compared to just encoding the path to the src attribute?

+1
image asp.net-mvc
source share
1 answer

A small but measurable effect on performance. However, performance is absolutely irrelevant until it becomes very relevant. Therefore, if your server does not bend, or your users must wait for their pages to load, and you need to start softening, do not worry about performance.

Do not worry about the following: you will need to re-implement the caching strategy on the server, since IIS controls what is requested directly for static files. You also need to make sure that you manage client-side caching with the correct headers included in the response. Ultimately, just ask yourself if you need to reinvent the method of serving static files from the server.

0
source share

All Articles