I have this MVC view that has a list of images, these images are dynamic so they come from a controller. To simplify things this controller has only this code:
[OutputCache(Duration = 0, NoStore = true, Location = OutputCacheLocation.None)]
public ActionResult RenderImage(int id)
{
return File(@"C:\Users\Pictures\myimage.png", "image/png");
}
I'm not caching things to prove my point.
My view requests 8 images all with a different id, and the timings are horrible:
Sometimes it's fast for some images (which are all the same) and on each refresh it's different, can't find a pattern in it.
The app is hosted in IIS and the timetaken in the server logs shows it's the server that is eating up the time:
Has anyone a clue why this happens? If I request the images individually (not in the page) it's always fast.
10 Ways to Speed Up Your ASP.NET MVC Application. 1 1. Application Caching. Caching is one of those programming techniques that should be used as a last resort, but it definitely accelerates your ... 2 2. Optimize Your Images. 3 3. Use Sprites. 4 4. ETags. 5 5. Bundle/Minify JavaScript/CSS. More items
So, you should prefer to use small file which can be loaded faster or single file which load faster rather than multiple file. In MVC there are two concepts behind this Bundling and Minification. This will help your site to make it faster and decrease the load time.
As we know that performance is an important part for every application on production. If any website is facing issue of performance then the users do not prefer to use that website. There are many ways to improve the performance of a website in ASP.NET MVC. I am going to demonstrate one by one. You should always use the debug build on production.
Loading images on the web can be a pain, especially if you are doing a website mainly for mobile devices. Because wireless connection is used in such cases, the transfer speed is often slower compared to a wired connection and therefore the content loads slower.
Turns out this is the solution in my case:
[SessionState(System.Web.SessionState.SessionStateBehavior.Disabled)]
user1394965 suggested this as the answer.. but his answer is gone?!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With