加载绑定到转发器控件的图像时面临的问题 [英] Facing problem with loading images binded to a repeater control

查看:63
本文介绍了加载绑定到转发器控件的图像时面临的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我面临图像加载时间的问题.在我的表单中,我将图像服务器控件放置在转发器控件中.中继器控件每次绑定至少300张图像.当我们想一次查看所有图像时,该页面需要花费很多时间(至少3至4分钟)来显示.但是我需要页面应该快速加载.

图片网址来自实际位置.与图片相关的信息来自数据库.

我正在使用.net framework 3.5和C#.net作为asp.net Web应用程序中的语言.

怎么解决呢?有人可以建议吗?


谢谢

Hi All,

I am facing problem with images loading time. In my form I have image server control placed in repeater control. The repeater control every time binds atleast 300 images. When we want to see all the images at a time the page is taking lot of time(atleast 3 to 4 mins) to display. But I need the page should be loaded fast.

The image url is from physical location.And the information related to image is coming from database.

I am using .net framework 3.5 and C#.net as language in asp.net web application.

How can this be solved??Can anyone suggest???


Thank you

推荐答案

这是我对CodeProject中任何问题的第一个答案.希望这会有所帮助.

我在这里看到两个可能的性能问题:

1. HTTP允许每个主机仅允许2个并发连接(在IE8和现代浏览器中,总共6个并发连接)在这两个连接中,一个保留用于加载JS文件(直到所有JS文件被加载),另一个保留用于加载其他内容(标记,图形等).

因此,在最坏的情况下,您将只能获得一个连接来一张一张地加载所有图像.在这种情况下,即使您的浏览器将向服务器发送异步URL请求,这些请求也将排队并作为同步请求执行.

要解决此问题,可以使用CDN(内容交付网络)的概念.也就是说,您使用不包含主机URL的URL公开图像.最好的情况是,您可以使用3个此类CDN站点来提供图像(例如,Say,images1.cdn.com,images2.cdn.com,images3.cdn.com),这些站点实际上将从单个位置加载图像并服务于浏览器请求.或者,至少您可以使用其他CDN站点来提供图像.

因此,假设您的浏览器已加载所有JS文件和标记,则它可以使用所有6个连接(每个主机2个)从CDN站点加载图像(如果您使用3个CDN站点存储图像).这将使您的浏览器可以同时利用其所有允许的6个连接来异步加载图像,从而提高性能.

后续来自浏览器的相同图像的URL请求应从浏览器的缓存中提供,因此图像加载速度甚至更快.

2.您将图像存储在哪里?在数据库中?或者,直接从文件系统.
如果图像数据是从数据库中加载的,请尝试调查图像检索操作的性能并查看任何性能改进选项.如果通过任何复杂的逻辑检索了映像,请尝试将映像缓存到磁盘中的预配置位置,并在后续请求时从缓存位置提供映像.甚至,考虑将映像存储在文件系统中并从那里进行服务,而不是存储在数据库中(因为这样可以提供更好的性能).

此外,您可以调查代码的其他部分(从数据库检索数据,数据处理,ViewState等)以优化整体性能.

希望能帮助到你.干杯!
This is my first ever answer to any question in CodeProject. Hope, this will help.

I see two probable performance issue here:

1. HTTP allows to allow 2 concurrent connections only per host, (6 concurrent connections in total, in IE8 and modern browsers) Among these two connections, one is reserved for loading JS files (Until all JS files is loaded) and another is reserved for loading other contents (markups, graphics etc).

So, in worst case, you will get only one connection to load all of your images one by one. In this case, even though your browser will send asynchronous URL request to the server, these request will be queued and will perform as synchronous request.

To solve this issue, you can use the concept of CDN (Content Delivery Network). That means, you expose your images using URLs that does not contain your host URL. In best case, you can use 3 such CDN sites for serving images (Say, images1.cdn.com, images2.cdn.com, images3.cdn.com) which would actually load the images from a single location and serve to browser request. Or, at least you can use a different CDN site for serving the images.

So, assuming that your browser have loaded all JS files and markups, it can use all 6 connections (2 per host) to load the images from the CDN sites (If you use 3 CDN sites for images). This will allow your browser to utilize its all permitted 6 connections simultaneously to load images asynchronously and will boost up performance.

Subsequent URL request for the same images from the browser should be served from the browser''s cache and hence, images would load even faster.

2. Where do you store your images? In the database? Or, directly from the file system.
If the image data is loaded from the database, try to investigate the image retrieval operation''s performance and see any performance improvement options. If the images are retrieved by any complex logic, try to cache the image to a pre-configured location in the disk and serve the images from the cache location on subsequent request. Even, consider storing the images in file system and serving from there, instead of storing in database (As this would give better performance).

Besides, you can investigate other parts of your codes (Data retrieval from the database, Data processing, ViewState etc) to optimize the overall performance.

Hope it helps. Cheers!


这篇关于加载绑定到转发器控件的图像时面临的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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