OK, here is the question, I have a asp.net website, there is an aspx page called GetThumbnail.aspx, the code is like below:
string newThumbnailPath = ReaderUtilities.GetThumbnailPath(ptiId, highQuality ? ZoomLevel.L : ZoomLevel.S);
Response.Clear();
if (File.Exists(newThumbnailPath))
{
Response.ContentType = "image/jpg";
Response.TransmitFile(newThumbnailPath);
}
That is it. the new newThumbnailPath is a network share path, usually like D:ImagesCache00001001230012345600123456-sml-1.jpg
Then in my website there is a searchResult.aspx, when user type some keyword to search, I will display the searchresult.aspx page, inside the searchResult.aspx, I will display 10 images, the code is below:
<img rel="429746" src="/GetThumbnail.aspx?p=429746" class="cover-img draggable">
OK, the question is, everytime, on production server, there must be several images loading very slow, say 8 images load within averagely 1 second, but 2 images take 7 or 9 seconds to load. All the images are small, and they don’t need to resize, I used firebug Net to check, the slow loading images’ DNS lookup, Connecting and Sending are all almost 1ms, and Receiving is 200 or 300ms, but the Waiting takes 8 or 9 seconds.
I thought it is because of IO, but why most of images are quick, just some and randomly, any help. I really appreciate it.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Because you use .aspx page (and not handler), and because the images loaded by browser not one by one, but many together, I suspect that you felt on the session lock of the page and that’s why this delay.
Try to set EnableSessionState="false" on the page.
eg:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.WebForm1"
EnableSessionState="false" %>
By the way, if you change the aspx page to a handler page you going to gain some more speed because the handler page did not make all the calls that a normally page do.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0