/* Style Definitions */ table.MsoNormalTable {mso-style-name: ordinary form; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}
Chapter 1Open website slow status analysis
When the company accesses theVIP website deployed in the IDC computer room, it will feel very slow. What causes this? In order to shorten the response time of the page and improve our user experience, we need to know what users spend their time waiting for.
You can track our login page, as shown in the figure belowWe can analyze it from the above picture,
HTMLThe document only accounts for 20% of the total response time, and the other 80% response time is used to download JS, CSS, images, etc. components. Therefore, the WEB front-end has a lot of room for optimization. We will comprehensively consider the two aspects of WEB’s front-end optimization and back-end optimization to give a WEB performance optimization plan. .
Chapter 2
Reduce as much as possible Optimization rules of the front desk 1.HTTP Requests
There are several common methods to effectively reduce
, Request: 1Merge scripts and style files, for example, you can combine multiple CSS files into one , combine multiple JS files into one. 2
、CSS Sprites Use CSS background Related elements to perform absolute positioning of the background image,Combine multiple images a picture. 2.
Use browser cache When users browse different pages of the website, a lot of content is repeated, such as the same JS, CSS, pictures, etc. If we could suggest or even force browsers to cache these files locally, it would significantly reduce the amount of traffic generated by the page, thereby reducing page load times. According to the server-side responseheader, a file has several different levels of cache status for the browser. 1. The server tells the browser not to cache this file and to update the file on the server every time. 2. The server does not give any instructions to the browser. 3. In the last transmission, the server sent Last-Modified or Etag data to the browser. When browsing again, the browser These data will be submitted to the server to verify whether the local version is the latest. If it is the latest, the server will return the 304 code, telling the browser to use the local version directly, otherwise download the new version. Generally speaking, if there are and only static files, the server will give these data. 4. The server forces the browser to cache files and sets an expiration time. Before the cache expires, the browser will directly use the local cache file without any communication with the server. What we have to do is to try to force the browser to the fourth state, especially for JS, CSS, pictures and other changes that are relatively large Fewer files. Use compression components and Firefox browsers support clientGZIP, before transmission, use GZIP to compress and then transmit it to the client. After the client receives it, it will be decompressed by the browser. Although this slightly takes up some CPU of the server and the client, it will change What comes is higher bandwidth utilization. For plain text, the compression rate is quite impressive. If each user saves 50% of bandwidth, then the rented bandwidth can serve twice as many customers and shorten the data transmission time. images and JS The easiest way to preload images is to JavaScript Instantiate a new Image() object, and then pass in the URL of the image to be loaded as a parameter. function preLoadImg(url) {
var img = new Image();
img.src = url;
}
You can preload JS and pictures on the login page
5.Put the script at the bottom
The problems caused by placing the script at the top,
1,Use script , progressive rendering will be blocked for content located below the script
2,Parallel downloads will be blocked while downloading the script
Putting it at the bottom may cause JS errors. When the script is not loaded, the user triggers the script event.
Consider the situation comprehensively.
6.Place the style file at the top of the page
If the style sheet is not loaded, building the rendering tree is a waste. There may be two situations when the style file is placed at the bottom of the page:
1, White screen
2, Flashing of unstyled content
7.Use external JS and CSS
turn the inline JS and CSS into external JS, CSS. Reduce repeated downloading of inline JS and CSS.
8. Split components into multiple domains
Page request analysis A
From input URL
The following5 steps are required to render the page1
.Enter the URL address or click on a link of URL
2. The browser parses the IP address # corresponding to
URLbased on the URL address, combined with DNS ## 3. Send HTTP request
4. Start connecting to the requested server and request related content
5. The browser parses the content returned from the server and displays the page.
The above is basically the basic process of a page from request to implementation. Below we will Analyze this process.
When you enter URL, the browser will know this URLWhat is the corresponding IP? Only by knowing the IP address can the browser prepare to send the request to the specified server. Specifically IP and port number. The browser's DNS parser is responsible for parsing URL into the correct IP address. This parsing process takes time, and during this parsing time period, the browser cannot download anything from the server. Browsers and operating systems provide DNS resolution caching support. After obtaining the IP address, the browser sends a HTTP request to the server. The process is as follows :
1. The browser requests the server to open the connection by sending a TCP packet
2. The server also responds to the client's browser by sending a packet, telling the browser that the connection is open.
3. The browser sends a GET request of HTTP. This request contains a lot of things, such as our common cookie and other headHeader information.
In this way, a request is sent.
After the request is sent, it is the server's business. The server-side program sends the final result to the client.
In fact, the first thing to reach the browser is the documents of html. The so-called documents of html are pure htmlCode does not include any pictures, scripts, CSS, etc. That is, the html structure of the page. Because what is returned at this time is only the html structure of the page. The time it takes for this html document to be sent to the browser is very short, generally accounting for about 10% of the entire response time.
After this, the basic skeleton of the page is in the browser. The next step is the process of the browser parsing the page, which is a step-by-step analysis from top to bottom## The skeleton of #html is gone.
If the img tag is encountered in the html document at this time, the browser will send a HTTP request to this The URL address of the img response is used to obtain the image and then present it. If there are many pictures in the html document, flash, then the browser will request them one by one and then render them. If each picture needs to be requested, then it must be done before The steps mentioned: parse url, open tcp connection, etc. Opening a connection also consumes resources. Just like when we are accessing a database, we try to open as few database connections as possible and use more connections in the connection pool. For the same reason, tcp connections can also be reused. http1.1 proposed the concept of persistent connection (persistent connection), which means that the same HTTP connection can handle multiple requests at the same time, reducing tcpConnection.
When the html skeleton of the page is loaded,the browser begins to parse the tags in the page,from Start analyzing from top to bottom.
The first is the parsing of the head tag. If it is found that there is a JS script to be quoted in head, then The browser begins to request the script at this time, and the parsing process of the entire page stops until the JS request is completed. After that, the page is parsed downwards, such as parsing the body tag. If there is an img tag in body, the browser will request img##. #srcThe corresponding resource, if there are multiple img tags, then the browser will parse them one by one, and the parsing will not wait like JS, Will download concurrently.
The above is the detailed content of Detailed introduction to Web performance optimization solutions. For more information, please follow other related articles on the PHP Chinese website!

译者 | 李睿审校 | 孙淑娟Web Speech API是一种Web技术,允许用户将语音数据合并到应用程序中。它可以通过浏览器将语音转换为文本,反之亦然。Web Speech API于2012年由W3C社区引入。而在十年之后,这个API仍在开发中,这是因为浏览器兼容性有限。该API既支持短时输入片段,例如一个口头命令,也支持长时连续的输入。广泛的听写能力使它非常适合与Applause应用程序集成,而简短的输入很适合语言翻译。语音识别对可访问性产生了巨大的影响。残疾用户可以使用语音更轻松地浏览

docker部署javaweb系统1.在root目录下创建一个路径test/appmkdirtest&&cdtest&&mkdirapp&&cdapp2.将apache-tomcat-7.0.29.tar.gz及jdk-7u25-linux-x64.tar.gz拷贝到app目录下3.解压两个tar.gz文件tar-zxvfapache-tomcat-7.0.29.tar.gztar-zxvfjdk-7u25-linux-x64.tar.gz4.对解

web端指的是电脑端的网页版。在网页设计中我们称web为网页,它表现为三种形式,分别是超文本(hypertext)、超媒体(hypermedia)和超文本传输协议(HTTP)。

区别:1、前端指的是用户可见的界面,后端是指用户看不见的东西,考虑的是底层业务逻辑的实现,平台的稳定性与性能等。2、前端开发用到的技术包括html5、css3、js、jquery、Bootstrap、Node.js、Vue等;而后端开发用到的是java、php、Http协议等服务器技术。3、从应用范围来看,前端开发不仅被常人所知,且应用场景也要比后端广泛的太多太多。

和它本身的轻便一样,Bottle库的使用也十分简单。相信在看到本文前,读者对python也已经有了简单的了解。那么究竟何种神秘的操作,才能用百行代码完成一个服务器的功能?让我们拭目以待。1. Bottle库安装1)使用pip安装2)下载Bottle文件https://github.com/bottlepy/bottle/blob/master/bottle.py2.“HelloWorld!”所谓万事功成先HelloWorld,从这个简单的示例中,了解Bottle的基本机制。先上代码:首先我们从b

web前端打包工具有:1、Webpack,是一个模块化管理工具和打包工具可以将不同模块的文件打包整合在一起,并且保证它们之间的引用正确,执行有序;2、Grunt,一个前端打包构建工具;3、Gulp,用代码方式来写打包脚本;4、Rollup,ES6模块化打包工具;5、Parcel,一款速度极快、零配置的web应用程序打包器;6、equireJS,是一个JS文件和模块加载器。

怎么解决高并发大流量问题?下面本篇文章就来给大家分享下高并发大流量web解决思路及方案,希望对大家有所帮助!

web有前端,也有后端。web前端也被称为“客户端”,是关于用户可以看到和体验的网站的视觉方面,即用户所看到的一切Web浏览器展示的内容,涉及用户可以看到,触摸和体验的一切。web后端也称为“服务器端”,是用户在浏览器中无法查看和交互的所有内容,web后端负责存储和组织数据,并确保web前端的所有内容都能正常工作。web后端与前端通信,发送和接收信息以显示为网页。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
