简体   繁体   English

每页单服务器请求与SPA应用程序

[英]Single Server request per page vs SPA Application

I had the idea to make a SPA application using angularJS and then just sending AJAX updates to the server when I need. 我的想法是使用angularJS制作SPA应用程序,然后在需要时仅将AJAX更新发送到服务器。

My initial idea would be make the client application fly, but if I have to do an AJAX round trip to the server, I think the time would be approximately the same as to request a single web page. 我最初的想法是使客户端应用程序运行,但是如果我必须对服务器进行AJAX往返,我认为时间大约与请求单个Web页面相同。

Requesting a page just has more bytes of data, is not like I'm requesting 20 resources like in this article: https://community.compuwareapm.com/community/display/PUB/Best+Practices+on+Network+Requests+and+Roundtrips 请求页面仅具有更多字节的数据,这与本文中我请求20种资源的感觉不同: https : //community.compuwareapm.com/community/display/PUB/Best+Practices+on+Network+Requests+和+往返

I would be requesting a page or resource per request. 我会在每个请求中请求页面或资源。

So in the end even if I create my client side application as a SPA using angularJS, these requests (would have to be synchronous and show a please wait message while they don't return, as I don't want to user to take more actions before I make sure his request passes validation and is processed correctly) would take some time and make user wait, just about the same time as requesting a full page. 因此,最后,即使我使用angularJS将客户端应用程序创建为SPA,这些请求(也必须保持同步并在不返回时显示请稍等的消息,因为我不想用户接受更多请求在确保他的请求通过验证并得到正确处理之前采取的一系列操作)将花费一些时间并使用户等待,几乎与请求整个页面的时间相同。

I think SPA pages would be very useful if I have like a wizard on my app with multiple pages/steps and at the end, submit the results of wizard, to the server, which I don't. 我认为,如果我在自己的应用中拥有一个包含多个页面/步骤的向导,并且最后将向导的结果提交给服务器,而我却没有,SPA页面将非常有用。

Also found this article: https://help.optimizely.com/hc/en-us/articles/203326524-AngularJS-Backbone-js-and-other-Single-Page-Applications 还找到了这篇文章: https : //help.optimizely.com/hc/en-us/articles/203326524-AngularJS-Backbone-js-and-other-Single-Page-Applications

One of the biggest advantages of Single Page Apps is that they reduce data transfer. 单页应用程序的最大优势之一是它们减少了数据传输。 As a result, pages after the initial loading usually can be displayed faster and seem more interactive. 因此,初始加载后的页面通常可以显示得更快,并且看起来更具交互性。

But I don't believe this last quote is really true. 但是我不相信最后的引用是真的。

Am I right, or is there a way that I'm not seeing to build an application that would look like it's executing locally? 我是对的,还是没有办法构建看起来像在本地执行的应用程序?

I know how guys will start saying "depends on what you want", but lets focus on this scenario where there's no wizards. 我知道人们将如何开始说“取决于您想要的东西”,但让我们关注这种没有向导的情况。

What ever you said is right. 你所说的都是对的。 But most of the frameworks(Angular,BackBone) you take they are going to cache the templates of html on the browser so the rendering would be pretty fast compared to the normal applications. 但是您采用的大多数框架(Angular,BackBone)都将在浏览器中缓存html模板,因此与常规应用程序相比,呈现速度非常快。 Traditional apps will have to fetch the html from the server for each request which is a time consuming one. 传统的应用程序将不得不为每个请求从服务器获取html,这是一个耗时的过程。

Hope this helps you!!! 希望这对您有帮助!!!

If you are wanting to go through that syncronous server side validation step for each page request, then there is probably no big advantage to using AngularJS. 如果您想针对每个页面请求执行同步服务器端验证步骤,那么使用AngularJS可能没有太大优势。

If you are requesting a page and then manipulating that page's contents once it's loaded you might want to consider AngularJS. 如果您请求一个页面,然后在页面加载后对其进行操作,则可能需要考虑使用AngularJS。 A good example would be requesting a page that displays a list of items. 一个很好的例子是请求一个显示项目列表的页面。 Now let's say we want to search that list or order it in different ways. 现在假设我们要搜索该列表或以不同的方式对其进行排序。 Rather than using AJAX to call the server to filter the list and then re-render it, it could be much faster to user AngularJS to filter and re-render the list without making any further requests to the server. 与其使用AJAX调用服务器来过滤列表然后重新呈现,不如对用户AngularJS进行过滤和重新呈现列表要快得多,而无需向服务器发出任何其他请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用AngularJS和Sitecore(SPA)构建单页应用程序 - Building a Single Page Application with AngularJS and Sitecore (SPA) 概念说明SPA(单页应用程序) - Concept explanation SPA (Single Page Application) 为单页应用程序 (SPA) 创建链接以登陆不同的选项卡 - create a link for a single page application (SPA) to land on different tab PageSpeed服务/库如何帮助单页应用程序(SPA)? - How does PageSpeed Service/Library helps a Single Page Application (SPA)? 在AngularJs单页面应用程序中发布请求 - Post request in an AngularJs single page application 使用单页应用程序(SPA)时如何在不刷新浏览器的情况下处理过期文件? - How to handle expired files without refreshing the browser when using Single Page Application (SPA)? Angular JS - 非单页SPA的路径 - Angular JS - Route to Non Single Page SPA 使用编码的UI自动执行针对角度SPA(单页应用程序)的UI测试时,单击主页上的图标不起作用 - While automating UI tests for angular SPA (Single Page Application) using Coded UI, clicking icons on home page does not work nodeJS,angularJS应用程序中的页面请求上的服务器身份验证 - Server authentication on page request in nodeJS, angularJS Application 如何删除SPA中特定页面的应用程序缓存 - how to remove the application cache for specific page in SPA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM