阿贾克斯 - 最佳实践/方法加载三级数据 [英] Ajax - best practice/approach for loading tertiary data

查看:132
本文介绍了阿贾克斯 - 最佳实践/方法加载三级数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于解决对在我建立一个应用程序加载额外的数据的方法有些困难。该应用程序是一个CMS在单页由许多碎片 - 一些可重复使用的,其他人独占

I'm having some difficulty on settling on an approach for loading additional data in an application that I am building. The app is a CMS in which a single page consists of many fragments--some reusable, others exclusive.

独家片段的一个例子可能是一个描述/作者meta标签,而可重复使用的片段可能是一个链接列表。

An example of an exclusive fragment might be a description/author meta tag, whereas a reusable fragment might be a list of links.

我目前的做法是加载必要的数据,构成了大量的页面,例如:主体内容,标题,蛞蝓,日期(发布/到期/修改)。之后,部分加载和UI已经准备好,我打开2个额外的数据集:元标记的集合;片段的集合

My current approach is to load the essential data that makes up the bulk of the page, e.g. Main body content, title,slug, dates (publish/expiration/modified). After that portion is loaded and the ui is ready, I load 2 additional datasets: a collection of metatags; a collection of fragments.

我表示授予有: 1.可扩展性 2.速度 3.可维护性

My confers are: 1. Scalability 2. Speed 3. Maintainability

是我的做法的声音或者我应该考虑另一种方法?

Is my approach sound or should I consider another approach?

推荐答案

我假设你正在使用AJAX来延迟加载上面提到的。

I am assuming that you are using AJAX for lazy loading mentioned above.

时的做法声音? 在回答你的问题取决于如何快速将整个页面加载(包括片段)。当我们要创建的页面的观感加载,使用户在心理上不喜欢等待你的技术被使用,

Is your approach sound? The answer to your question depends on how fast the entire page is loading (including the fragments). Your technique is used when we want to create the perception of the page is loaded so the user psychologically don't feel like waiting,

这技术用于当整个页面被认为太长时间来加载。由于措施载入时间太长是主观的,让我们考虑8秒作为一个例子。如果整个页面需要8秒,载入和部分页面,如主体等需要3秒钟,然后明智的做法是先加载的部分,这样用户在心理上不喜欢等待,持续8秒。

That technique is used when the entire page is deemed too long to load. As the measures of "too long to load" is subjective, let's consider 8 seconds as an example. If the entire page takes 8 seconds to load and partial page such as main body, etc takes 3 seconds, then it is wise to load those portion first so the user psychologically don't feel like waiting for 8 seconds.

至于你的3个标准:

  • 可扩展性:延迟加载会增加HTTP数量回调到服务器,从而引入额外的负荷总量的服务器调用,以及采取了并发连接数的可能性的数量方面。因此,延迟加载引入额外开销到服务器。但是,如果部署环境是群集正常,不应该发生任何问题你。

  • Scalability : Lazy loading would increase the number of http calls back to the server and thus introducing additional loads in terms of number of total calls to the server as well as the possibility of taking up the number of concurrent connections. As such, lazy loading introduce additional overhead to the servers. However, if your deployment environment is a clustered properly, it should not be causing any major problem for you.

速度: 这是回到我之前说的。如果你的整个页面加载速度非常快,然后做碎片的延迟加载实际上可以慢下来(总共秒计),因为你在做额外的HTTP服务器调用。在这种情况下,你是不是帮助用户的看法也是如此。但是,如果速度加载整个页面是长,则技术意义,因为它提高速度的用户感知,甚至总速度装载的时间可能是更大的

Speed: This is back to what I said before. If your entire page load very fast then doing the lazy loading of the fragments could actually slow it down (in terms of total seconds) since you are making extra HTTP calls to the server. In this case, you are not helping the perception of the users as well. However, if the speed to load the entire page is long, then the technique make sense as it improve user's perception of speed even total time of speed loading is probably greater.

可维护性:一个良好的实施将使之间加载整个页面,并通过几个简单的code片段选择。这将意味着,你已经写了维护和灵活的code。

Maintainability: A good implementation would enable to choose between loading entire page and in fragments by few simple code. That would signify that you have written a maintainable and flexible code.

这篇关于阿贾克斯 - 最佳实践/方法加载三级数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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