GVKun编程网logo

单页应用(Single Page Application)的搜索引擎优化(单页面seo搜索引擎优化)

8

此处将为大家介绍关于单页应用的详细内容,并且为您解答有关SinglePageApplication的搜索引擎优化的相关问题,此外,我们还将为您介绍关于AddingOpenSource3DPhysics

此处将为大家介绍关于单页应用的详细内容,并且为您解答有关Single Page Application的搜索引擎优化的相关问题,此外,我们还将为您介绍关于Adding Open Source 3D Physics to Your iOS Applications (3)Using Bullet in Your iOS Application、Angular 应用的 browser Application 和 server Application bundle、Application & Session & Request & Page、Application application_1512618719369_147804 failed 2 times due to ApplicationMaster for attempt app的有用信息。

本文目录一览:

单页应用(Single Page Application)的搜索引擎优化(单页面seo搜索引擎优化)

单页应用(Single Page Application)的搜索引擎优化(单页面seo搜索引擎优化)

单页应用并不是一个全新发明的技术,而是随着互联网的发展,越来越受web开发者欢迎,单页应用的体验可以模拟原生应用,一次开发,多端兼容,效果酷炫,节省成本。然而,由于单页应用基本全部使用JS,受制于SEO效果,目前国内使用单页应页技术的网站还是少之又少。在已知使用单页应用的站点中,携程旅行的SEO效果一直不错,那么今天,我们请携程旅行SEO技术负责人安琦老师为我们分享了单页应用SEO解决四大方案,其中第四套是目前携程旅行采用的技术方案,监控数据表明效果符合预期:

一、单页应用?此SPA不是彼SPA…

我们所说的“单页应用”都为Single Page Application的直译,基本市面上“单页面应用”、“One Page Application”、“SPA”及某些语境下的“webapp ” 都是指这一类移动站点。

那么典型的SPA是什么样子?我们用手机看看这条URL,http://cc-ng-z.azurewebsites.net/,可以衍生想象一下乘以N倍的:切换页面无需加载的效果,HTML和JS无法比拟的动画,以及对原生APP的追求……

*案例采用了angularJS这个鼎鼎大名的框架

关于HTML5及单页应用的处境,推荐以下两篇文章,第二篇实际上是百度UMX写的,但是现在原文删掉了,可以对自己的移动站点在技术架构上有个抉择和处理:

HTML5移动应用开发的生态环境简介

论Web App、Hybrid App以及Native App的设计差异

二,高科技永远连累我们干苦力的

为什么这么写,因为SPA对SEO损伤很大,非常大。

优点当然毋庸置疑:效果酷炫,我在视觉和产品面前无从反驳;性能高速度快,全JS嘛当然快,我在运维和产品面前无言以对;运算分散,异步加载,又省硬件又省流量,我在开发和产品面前彻底投降;JS前后端,一个人干一个站的活儿——关于这一点,我在老板、HR和产品面前哭的像一个孩子。总之,在各路人马的一番碾压后,我手里的网站改版了,一个SPA诞生了。

问题接踵而来:我发现所有页面都变成了全JS生成;所有URL中参数前面都被#分割;第三方统计系统无法再正常工作;PC和移动的适配正则全部失效了;所有人都高兴了,只有你,做SEO的、做网站优化的,欲哭无泪。

实际上我观察下来,只要使用了SPA架构的站点或多或少收到伤害,当看到有些大站点没做处理,只有可能搜索对于他们是个微不足道的渠道,比如锤子手机官网甚至不可思议地在PC站点上使用了类似架构,我相信他们的索引是有点问题的。这让我想到知乎上一个问题,说AMAZON的URL那么乱(当时)是因为他们不注重SEO吗?答案是不是,是他们更注重tracking。同理,SPA带来的优点胜过SEO,我被PK掉了。

三,求人不如求己

在SPA项目面前,我发现我被放在了所有人的对立面,无法抗拒这种时髦架构的上线,当然不得不说效果确实比WAP即视感的站点高端和好用太多,不要螳臂当车逆历史车轮而动。既然反抗也很痛,那么享受吧!我知道,我还和搜索引擎在一起;老板要的是解决方案,当然回滚这种方案会让我先滚。

让我们看看一个典型的SPA网站架构,和传统的服务端生成内容不同,在传统的网站,当你发起请求的时候,页面的组装是在服务器上完成的,反馈给浏览器的是已经完成组装的HTML内容;而之于SPA,服务端负责了数据和素材的存储,页面的逻辑执行和组装是在浏览器上通过Javascript完成和呈现的,这也就意味着,SPA不需要请求→接受、请求→接受、请求→接受、请求→接受这样玩了。完全凭借本地数据,即可完成基本的页面请求和访问。

基于此,当某人需要像APP那样切换页面但不刷新,并要在此基础上做文章时,#(井号)这个奇葩的符号粉墨登场,完成了“又要本地传输数据又不需要刷新页面”这个奇葩需求的历史任务,给单页应用的可抓取性重重一击。整个SPA的网站,URL不可抓取,页面内容不可抓取,糟透了。

解决思路倒也简单,围绕全JS和URL可用解决问题。

【方案一:尽人皆知的Google抓取AJAX方案】

如何让搜索引擎抓取AJAX内容?

A proposal for making AJAX crawlable

Google给了官方指导,并在Twitter上做了个最大的case,但后来T家放弃了,我想更多是T战略上的放弃。腾讯的ISUX博客上也曾经推广过这种方式,居然是在2014年,如下文:单页应用的SEO浅谈

总的来说,这种方案可以兼容Google,如果资源实在有限,有着能抓多少是多少的心态,可以试试。主要不幸的是,5年前Google已和我们再见了

【方案二:再做一个服务端生成内容的镜像网站】

说实话,量级不大的网站并且极度依赖搜索引擎这个渠道的情况下,这不失为一种方案,第一,蜘蛛绝对可抓取;第二,URL规则的完全可控(要知道现在流行的路由方式,在配置URL规则上相对于URLrewrite是有天生缺陷的);第三,SPA模式URL衍生的所有问题不再是问题。

但是面临的问题也令我望而却步:我要说服team再维护一个一模一样的网站,不是做完了事,是维护,这意味着修Bug要有资源修,改版要有资源改(能说服自己搜索进来然后点两下看到的网站不一样吗?)、所有相关功能的测试、发布、常规测试,都要耦合在一起,当站点大到一定程度,流程前所未有地臃肿,推进无休止的争吵,所有烦恼包围着我,让我想静静。我预计自己会累垮,即使搞定了所有的资源,网站优化人员自身也将面临着非常繁重的工作,两个网站怎么融合,适配跳转怎么设定,是否需要主动判断蜘蛛展现不同的内容,内链入口怎么放,都是耦合,且是硬耦合,网站大了页面多了,越做耦合越多,以后一碰就是坑。

【方案三:HTML5 history 中的PushState】

还好,开发大大们总是不少奇巧淫技,这是个很”经典”的用法,配合<noscript>这个擦边球标签,既能实现URL的自定义,又能实现还算有效果的内容抓取。蜘蛛、浏览器,两方应对,给蜘蛛不带井号能抓取的URL,给浏览器访问非井号URL时中间做转换,这样的话每张页面都有了可抓取的URL,且依然使用着高逼格的SPA架构。内链可以做了,Sitemap可以做了,适配也轻松了。

但实际上,蜘蛛在这种页面上还是盲的,所有内容要仰仗于noscript这个标签里塞的数据,以及搜索引擎对这个标签的支持程度。

做到这一步,单就需求而言,搜索引擎的抓取从HTML规范讲完成了,但这种方式没有任何搜索承认过支持,包括最核心的那个对于noscript标签的支持。

【方案四:用更高效的方式完成两套页面】

再回到那个简单的架构图,SPA这种架构,渲染是在客户端(浏览器)完成的,大致流程如下:

蜘蛛无法执行JS,相应的页面内容无从抓取,弊端还是那个弊端。但我们知道,传统的服务端生成页面,response里已经是服务器渲染组装好的HTML代码,浏览器只负责正确地展现,蜘蛛负责正确的解析,所以,我们需要给蜘蛛渲染完成的HTML,那么你的框架需要兼容如下流程的功能。

我们看到,当访问为SEO所需页面的时候,数据传输到了SEO 服务器完成渲染和组装然后吐给浏览器和蜘蛛,那么蜘蛛拿到的即是完全可见且融合了SPA的页面——landing页都是蜘蛛可见的,接下去用户的点击都是SPA的页面。

需要注意的是,如果你是用URL来区分SPA架构与否,那么内链及入口要全部使用SEO URL,只为用户暴露SPA的链接,JS在这里阴差阳错地成为了优势,那些SPA的链接将比较难被抓取的。

其实可以不使用URL来区分,延伸想想。这样一个流程,也无多少高精尖元素,其实只是“依照条件”增加了一个服务端自动渲染的步骤,在架构方案上再细细夯实,可以实现一套代码两处运行、SEO页面可单独自定义功能、、同一张landing人和蜘蛛没有跳转,没有区别对待、全栈工程师的大量使用、SEO页面永远保持最新版等等省时省力的需求功能。

总之,如果你和我一样,有文章前面部分的抱怨,SPA架构势在必行,两套页面改版不能同步,单独多做一套可抓取页面没有太多资源投入,与此同时还是想以比较保守的方式给蜘蛛展现网站的内容,那么这个思路可以考虑,然后为自己量身定做。

关于单页应用的网站优化,在实践中我所经历过的这些吧。优化不是按部就班,作为从业人员要审时度势地采取不同方案,以结果为导向,上不了线,再好的优化也是个方案。

相关内容讨论请移步【学堂同学汇】《单页应用(Single Page Application)的搜索引擎优化》讨论帖

Adding Open Source 3D Physics to Your iOS Applications (3)Using Bullet in Your iOS Application

Adding Open Source 3D Physics to Your iOS Applications (3)Using Bullet in Your iOS Application

Using Bullet in Your iOS Application

All that remains is to build an application that actually uses Bullet and displays 3D objects. Apple's GLKit framework makes it relatively easy.

Make the view controller class generated by Xcode's Single View Application template into a subclass of GLKViewController instead of UIViewCintroller. The PViewController.h file in the tutorial sample code contains the following lines:

#import <GLKit/GLKit.h>
 PViewController : @interfaceGLKViewController

Next,edit the MainStoryboard.storyboard file generated by Xcode's Single View Application template. Set the class of the generated view to GLKView using Xcode's Identity inspector,shown in figure 12.

Figure 12 Setting the view's class to GLKView

Add the GLKit and OpenGLES frameworks to the project. The easiest way is to edit the project's Build Phases,as shown in figure 13. Press the + button in the Link Binary with Libraries section to add frameworks.

Figure 13 GLKit and OpenGLES frameworks added to the project

If you build and run the tutorial project Now,you should see a black screen. The next step is to create a physics simulation and draw something more interesting.

The tutorial source code includes a file named PAppDelegate.mm. The .mm extension tells Xcode to compile the file as Objective-C++ code intermixing C++ and Objective-C. The following code declares instance variables to store Bullet physics objects:

#import "PAppDelegate.h"
#include "btBulletDynamicsCommon.h"
#include <map>


 < *,*> 
   GModelShapeMap;


  ()
{
    *collisionConfiguration;
    *dispatcher;
    *overlappingPairCache;
    *solver;
    *dynamicsWorld;
   *> collisionShapes;
   
    modelShapeMap;
}

@endtypedefstd::mapPPhysicsObjectbtCollisionObject@interfacePAppDelegatebtDefaultCollisionConfigurationbtCollisiondispatcherbtbroadphaseInterfacebtSequentialImpulseConstraintSolverbtdiscreteDynamicsWorldbtAlignedobjectArray<btCollisionShapeGModelShapeMap

The GModelShapeMap modelShapeMap variable is used to store the relationships between Objective-C objects representing Boxes and spheres and the corresponding shapes simulated by Bullet. A C++ map is a standard class similar in function to Cocoa Touch'sNSDictionary class.

The physics simulation is initialized in PAppDelegate's -application:didFinishLaunchingWithOptions: method that's part of the Cocoa Touch standard application delegate protocol. The simulation is configured to use Earth's gravitational acceleration of -9.81 meters per second2. Comments explain the steps needed to initialize Bullet. Don't worry if it doesn't make much sense to you. It's boilerplate code.

/////////////////////////////////////////////////////////////////
// Creates needed physics simulation objects and configures
// properties such as the acceleration of gravity that seldom
// if ever change while the application executes.
- ()application:( *)application 
   didFinishLaunchingWithOptions:( *)launchOptions
{
    ///collision configuration contains default setup for memory,// collision setup. Advanced users can create their own 
   // configuration.
     =  
      ();
   
    ///use the default collision dispatcher. For parallel 
   // processing you can use a diffent dispatcher 
   // (see Extras/BulletMultiThreaded)
     = 	  
      ();
   
    ///btDbvtbroadphase is a good general purpose broadphase. You 
   // can also try out btAxis3Sweep.
     =  ();
   
    ///the default constraint solver. For parallel processing you 
   // can use a different solver (see Extras/BulletMultiThreaded)
     =  ;
   
     = 
       (,);
   
    ->setGravity(());
   
   return YES;
}BOOLUIApplicationNSDictionarycollisionConfigurationnewbtDefaultCollisionConfigurationdispatchernewbtCollisiondispatchercollisionConfigurationoverlappingPairCachenewbtDbvtbroadphasesolvernewbtSequentialImpulseConstraintSolverdynamicsWorldnewbtdiscreteDynamicsWorlddispatcheroverlappingPairCachesolvercollisionConfigurationdynamicsWorldbtVector30,-9.81,0

PAppDelegate's -applicationWillTerminate: method tears down the simulation built in -application:didFinishLaunchingWithOptions:. It's not necessary to implement -applicationWillTerminate: in the tutorial sample code because when the application terminates,iOS will automatically reclaim the memory and other resources consumed by the physics engine. The code is provided in PAppDelegate.mm as example to follow if you ever need to clean up the physics engine while the application continues to execute.

PAppDelegate provides the following -physicsUpdateWithelapsedtime: method. Call the method periodically to give the physics engine opportunities to recalculate object positions and orientations.

/////////////////////////////////////////////////////////////////
// Turn the crank on the physics simulation to calculate 
// positions and orientations of collision shapes if
// necessary. The simulation performs up to 32 interpolation
// steps depending on the amount of elapsed time,and each step
// represents 1/120 seconds of elapsed time.
- ()physicsUpdateWithelapsedtime:()seconds;
{
   dynamicsWorld->stepSimulation(seconds,/);
}voidNSTimeInterval321120.0f

That's all it takes to start using Bullet physics for iOS. The simulation doesn't produce any interesting results unless some objects are added and set in motion to collide with each other. It's time to create,register,and draw physics objects.

GLKit provides most of the features needed. The tutorial project includes files named sphere.h and cube.h containing data declarations for 3D shapes. The data consists of vertex positions and "normal" vectors. Each shape is drawn as a list of connected triangles. The normal vectors provide information used to calculate how much simulated light reflects from each triangle.

The PViewController class implements all of the drawing for the tutorial. The drawing code is suboptimal to keep the code simple,and it turns out not to matter at run time. Profiling the tutorial code reveals that less than 20% of the application's execution time is spent drawing. Even if the drawing code is removed entirely,the application only runs 20% faster.

PViewController declares the following properties. The baseEffect property stores an instance of GLKit's GLKBaseEffect class. Modern GPUs are programmable allowing almost unlimited flexibility when rendering 3D graphics. The programs running on the GPU are sometimes called effects. GLKBaseEffect encapsulates the GPU programs needed by simple applications so that you don't need to dive into GPU programming when getting started.

@interface  ()

@property (strong,nonatomic,readwrite)
    *baseEffect;
@property (strong,readwrite) 
    *BoxPhysicsObjects;
@property (strong,readwrite) 
    *spherePhysicsObjects;
@property (strong,readwrite) 
    *immovableBoxPhysicsObjects;
   
@endPViewControllerGLKBaseEffectNSMutableArrayNSMutableArrayNSMutableArray

Other than baseEffect,the other properties all store arrays of Objective-C objects representing spheres and Boxes in the simulation. Bullet only recalculates positions for physics objects that have mass. Objects created with zero mass are therefore immovable within the simulation. They don't become displaced when other objects collide or fall in response to gravity. The immovableBoxPhysicsObjects property stores an array of zero mass Boxes used to form a floor. Without a few immovable objects in the simulation,all of the other objects would quickly fall out of view as the result of simulated gravity.

Two GLKViewController methods provide the key to drawing with GLKit: -update and -glkView:drawInRect:. The –update method is called periodically in sync with the iOS device display refresh rate. The display always refreshes 60 times per second,butGLKViewController's default behavior is to call –update at 30Hz. In other words, –update is called once for every two display refreshes. GLKViewController can be configured to call –update at other rates,but 30 times per second works well for simulations. Right after calling –update, GLKViewController tells the view it controls to display,and the view calls back to GLKViewController's -glkView:drawInRect:. Therefore,you implement simulation update in –update and implement custom 3D drawing code in -glkView:drawInRect:.

/////////////////////////////////////////////////////////////////
// This method is called automatically at the update rate of the 
// receiver (default 30 Hz). This method is implemented to
// update the physics simulation and remove any simulated objects
// that have fallen out of view.
- ()update
{
    *appDelegate = 
      [[] ];
   
   [appDelegate :
      .];

   // Remove objects that have fallen out of view from the 
   // physics simulation
   [ ];
}voidPAppDelegateUIApplication sharedApplicationdelegatephysicsUpdateWithelapsedtimeselftimeSinceLastUpdateselfremoveOutOfViewObjects

The following drawing code sets baseEffect properties to match the orientation of the iOS device,specifies perspective,positions a light,and prepares for drawing 3D objects. Theaspect ratio is the ratio of a view's width to its height. The aspect ratio may change when an iOS device is rotated from portrait orientation to landscape and back. Perspectivedefines how much of the 3D scene is visible at once and how objects in the distance appear smaller than objects up close.

In the real world,we only see objects that reflect light into our eyes. We perceive the shape of objects because different amounts of light reflect for different parts of the objects. Setting the baseEffect's light position controls how OpenGL calculates the amount of simulated light reflected off each part of a virtual 3D object. Calling [self.baseEffect preparetoDraw] tells the base effect to prepare a suitable GPU program for execution.

/////////////////////////////////////////////////////////////////
// GLKView delegate method: Called by the view controller's view
// whenever Cocoa Touch asks the view controller's view to
// draw itself. (In this case,render into a frame buffer that
// shares memory with a Core Animation Layer)
- ()glkView:( *)view drawInRect:()rect
{
   // Calculate the aspect ratio for the scene and setup a 
   // perspective projection
      aspectRatio = 
   ()view. / ()view.;
   
   // Set the projection to match the aspect ratio
   .. = 
   (
      (),// Standard field of view
      aspectRatio,// Don't make near plane too close
      ); // Far arbitrarily far enough to contain scene
   
   // Configure a light
   ... = 
   (,);// Directional light
      
   [. ];

   // Clear Frame Buffer (erase prevIoUs drawing)
   (|);
   
   [ ];
   [ ];      
}voidGLKViewCGRectconstGLfloatGLfloatdrawableWidthGLfloatdrawableHeightselfbaseEffecttransform.projectionMatrixGLKMatrix4MakePerspectiveGLKMathdegreesToradians35.0f0.2f200.0fselfbaseEffectlight0positionGLKVector4Make0.6f1.0f0.4f0.0fselfbaseEffectpreparetoDrawglClearGL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BITselfdrawPhysicssphereObjectsselfdrawPhysicsBoxObjects

OpenGL ES is a technology for controlling GPUs. Parts of OpenGL ES execute on the GPU itself,and other parts execute on the cpu. Programs call a library of C functions provided by OpenGL to tell OpenGL what to do. The glClear() function,called in the tutorial's -glkView:drawInRect:, erases prevIoUs drawing and discards prevIoUsly calculated information about which 3D objects are in front of others.

PViewController's –drawPhysicssphereObjects and –drawPhysicsBoxObjects methods draw spheres and Boxes with positions and orientations calculated by the physics engine. Without going into a lot of detail,each of the methods calls OpenGL ES functions to specify where to find vertex data defining triangles. Then the triangles are drawn by calling code similar to the following:

      // Draw triangles using the first three vertices in the 
      // currently bound vertex buffer
      (,// Start with first vertex in currently bound buffer
         sphereNumVerts);glDrawArraysGL_TRIANGLES0

OpenGL ES can only draw points,lines segments,and triangles. Complex shapes are composed of many triangles. The shapes in this tutorial are defined in sphere.h and cube.h. The shapes were initially drawn in a free open source 3D modeling application called Blender. Modeling is the term used by artists who create 3D shapes. The created models are exported from Blender in .obj file format and then converted into C header files suitable for direct use with OpenGL. Conversion is performed by an open source Perl language script.

It takes a little more work to setup GLKit. PViewController's -viewDidLoad method shows representative boilerplate code. This article glosses over methods like PViewController's –addRandomPhysicsObject. The code for adding physics objects is straightforward and particular to this tutorial. You'll most likely add different objects with different logic in your physics simulation projects.

Conclusion

The simulation provides remarkably complex and varied interaction between objects. The downloadable code is available in two variants. The Physics zip file (3dphyslibios_physics.zip) contains a Physics folder with an Xcode project. If you have built the Bullet demo applications for Mac OS X,you can copy the Physics folder into your bullet-2.80-rev2531 folder,double-click the Physics.xcodeproj file and press Run. A separate larger PhysicsPlusBullet zip file (3dphyslibios_physicsplusbullet.zip) contains the tutorial example and the needed Bullet source code combined. As always with open source,it's better to get the source code directly from the maintainers instead of grabbing a snapshot preserved in a tutorial's .zip file. Nevertheless,if you're impatient,the PhysicsPlusBullet zip file will get you up and running quickly.

This article provided a whirlwind tour of two large and powerful frameworks,Bullet and GLKit. It's not difficult to combine the two technologies in iOS applications. Like many open source libraries,Bullet is relatively easy to compile for iOS in spite of quirks related to the tools and coding style used by the library's authors. GLKit enables development of interesting and visually complex 3D applications with very little code. The tutorial implements all of its drawing in about 200 lines of code including comments and blank lines.

If you are interested in a more thorough introduction to 3D graphics concepts and GLKit,my new book, Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming,is complete and available Now as a Rough Cut electronic edition. Look for the title at your favorite bookstore in the fall. Free sample codefrom the book is available.

Angular 应用的 browser Application 和 server Application bundle

Angular 应用的 browser Application 和 server Application bundle

我们在使用 yarn run 启动 Angular 应用时,注意到 browser Application 和 server Application bundle 的生成:

1.png
2.png

在 Angular 应用程序中,应用程序包含两个主要的部分:客户端应用程序和服务器应用程序。客户端应用程序是在 Web 浏览器中运行的 Angular 应用程序,而服务器应用程序是在服务器端运行的 Node.js 应用程序。

为了支持这两个应用程序,Angular 应用程序包括两种类型的应用程序包:浏览器应用程序包和服务器应用程序包。

Browser Application Bundles

浏览器应用程序包是客户端应用程序的一部分,它包含了 Angular 应用程序在浏览器中运行所需的所有代码和资产。浏览器应用程序包通常包含以下内容:

  1. 所有的 TypeScript 和 JavaScript 代码,包括 Angular 应用程序的组件、指令、管道、服务等等。
  2. 所有的模板文件,这些模板文件描述了 Angular 应用程序的用户界面。
  3. 所有的 CSS 和样式文件,这些文件定义了 Angular 应用程序的外观和样式。
  4. 所有的图像、字体和其他静态文件,这些文件用于提供 Angular 应用程序所需的所有资源。
  5. 所有的第三方库和依赖项,这些库和依赖项是 Angular 应用程序所需的所有扩展功能的基础。

浏览器应用程序包可以通过 Angular CLI 或其他打包工具(如 webpack 或 Rollup)生成。它通常包含一个或多个 JavaScript 文件,以及一些其他的资源文件,如 HTML、CSS 和图像文件。

Server Application Bundle

服务器应用程序包是服务器端应用程序的一部分,它包含了 Angular 应用程序在服务器端运行所需的所有代码和资产。服务器应用程序包通常包含以下内容:

  1. 所有的 TypeScript 和 JavaScript 代码,包括 Angular 应用程序的服务器端渲染代码。
  2. 所有的模板文件,这些模板文件用于在服务器端生成 Angular 应用程序的初始 HTML。
  3. 所有的第三方库和依赖项,这些库和依赖项是 Angular 应用程序所需的所有扩展功能的基础。

服务器应用程序包可以通过 Angular CLI 或其他打包工具(如 webpack 或 Rollup)生成。它通常包含一个或多个 JavaScript 文件,以及一些其他的资源文件,如 HTML、CSS 和图像文件。

需要注意的是,服务器应用程序包通常不包含 Angular 应用程序的所有客户端资产,如组件、指令、管道、服务等等。这些资产通常会被打包到浏览器应用程序包中,因为它们只需要在浏览器中运行。

Application & Session & Request & Page

Application & Session & Request & Page

Web交互的最基本单位为HTTP请求。每个用户从进入网站到离开网站这段过程称为一个HTTP会话,一个服务器的运行过程中会有多个用户访问,就是多个HTTP会话。

Application

作用范围在服务器启动到服务器关闭为止。Application 的范围最大、停留的时间也最久,所以使用时要特别注意不然可能会造成服务器负载越来越重的情况。只要将数据存入Application对象,数据的范围 (Scope) 就为Application。

具有Application范围的对象被绑定到 javax.servlet.ServletContext 中。在Web应用程序运行期间,所有的页面都可以访问在这个范围内的对象。

Application对象的主要方法:
getAttribute(String name)     return Object     
getAttributeNames()             return Enumeration
getInitParameter(String name)
getServletInfo()
setAttribute(String name , Object object)

Session(会话)

HTTP会话开始到结束这段时间。Session 的作用范围为用户和服务器所连接的一段持续时间,与服务器断线,这个属性就无效了。

Session 的开始时刻比较容易判断,它从浏览器发出第一个HTTP请求即可认为会话开始。但结束时刻就不好判断了,因为浏览器关闭时并不会通知服务器,所以只能通过如下这种方法判断:如果一定的时间内客户端没有反应,则认为会话结束。Tomcat的默认值为120分钟,这个值也可以通过HttpSession的setMaxInactiveInterval()方法来设置。具有session范围的对象被绑定到 javax.servlet.http.HttpSession 对象中。

Session对象的主要方法:
getAttribute(String name) return Object
getAttributeNames() return Enumeration
getCreationTime() return long
getId() return String
getLastAccessedTime() return long
getMaxInactiveInterval() return int
removeAttribute(String name) void
setAttribute(String name , java.lang.Object value) void 

Requset

HTTP请求开始到结束这段时间。Request 的范围是在一网页发出请求到另一个网页之间。一个HTTP请求的处理可能需要多个Servlet合作,这几个Servlet之间可以通过某种方式传递信息,这个信息在请求结束后就失效。具有Request范围的对象被绑定到javax.servlet.ServletRequest 对象中。Request对象对于每一个客户请求都是不同的,所以对于每一个新的请求,都要重新创建和删除这个范围内的对象。

Request对象的主要方法:
getParameter(String name) return String
getParameterNames() return Enumeration
getParameterValues(String name) return String[]

Page

作用范围:当前页面从打开到关闭这段时间,它只能在同一个页面中有效。

具有Page范围的对象被绑定到 javax.servlet.jsp.PageContext 对象中。

Application application_1512618719369_147804 failed 2 times due to ApplicationMaster for attempt app

Application application_1512618719369_147804 failed 2 times due to ApplicationMaster for attempt app

今天遇到一个特别怪的问题,之前etl中的hive任务一直报错,持续一上午,也没有查出原因,错误的任务的日志也找到,原本可以找到原因,但是打开日志,心里面一凉,什么报错也没有,不知所错。最后观察报错的节点,最终集中到两台机器,那就看看是不是这两台机器的hadoop的程序引起的吗?看看他们的程序都在,但是查看nodemanager的日志一直报错,并且查看cpu,nodemanager进程占用的cpu达1000%多,马上眼前一亮,知道cpu占用太多,导致ap不能联系,导致任务失败,最后把这两台机器的nodemanager重启一下,观察了一下,任务不在报错。继续努力.............

我们今天的关于单页应用Single Page Application的搜索引擎优化的分享已经告一段落,感谢您的关注,如果您想了解更多关于Adding Open Source 3D Physics to Your iOS Applications (3)Using Bullet in Your iOS Application、Angular 应用的 browser Application 和 server Application bundle、Application & Session & Request & Page、Application application_1512618719369_147804 failed 2 times due to ApplicationMaster for attempt app的相关信息,请在本站查询。

本文标签: