A little experience of reducing the pressure on the server through the page structure

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

When a Web site to achieve large traffic in the short term, I want to give the technology the biggest problem is the server instability. At the same time, online thousands of IP, the CPU on the server will be brought 100%, resulting in a decline in the speed of access to the Web site, especially some slow network users, at this time easy to open the Web site. In the user experience and the site itself is an injury. As a page designer, how to reduce the number of server connections from the page structure of some experience, hope to be useful to everyone:

Website Picture optimization

Pictures I think is necessary for each site, or aesthetic on the pass; Small icons, background pictures, login boxes and so on. When you visit a page, each picture is the same number of links, if your home page has 20 small map, that is a user access, to occupy the number of 20 connections, 2000 people at the same time online, horror ah.

The solution to the picture problem is to integrate all the small graphs into a larger image, as shown below:

  

This turns 20 to 11 connections, in addition to reducing the number of connections, you can speed up the loading of the page picture, here I suggest you save for png-8 format, because it is smaller than gif,jpg,png-32, smaller means that you load the page faster, users can see the content of your site faster, Twofold。

Learn how to call these pictures:

For example, to invoke the Member login icon

Page:

<a class= "Login" heft= "#" > member Login </a>

CSS:

. Login{background:url ("picture. png") 0-100px no-repeat; height:30px; width:50px;} &lt;!-0-100px; refers to the location of the picture. Height and width are icons that look at the size of the icons and are fixed--&gt;

. Login{background:url ("picture. png") 0-100px no-repeat; height:30px; width:50px;}

This completes the call to the icon, is not very simple ah, quickly learn it.

Second, the website CSS optimization

Optimized in CSS, in addition to reducing the size of CSS, such as Marin,padding,font and other commonly used abbreviations outside. Like all the above Backgroud this can be abbreviated. Follows;

Page:

&lt;p&gt;&lt;a class= "Login" heft= "#" &gt; member Login &lt;/a&gt;&lt;a class= "Reg" heft= "#" &gt; member Registration &lt;/a&gt;&lt;a class= "Sell" heft= "#" &gt; I want to sell a car &lt;/a&gt;&lt;a class= "buy" heft= "#" &gt; I want a car &lt;/a&gt;&lt;/p&gt;

CSS:

Login{background:url (". /images/picture. png ") 0-100px no-repeat; height:30px; width:50px; . Reg{background:url (". /images/picture. png ") 0-100px no-repeat; height:30px; width:50px; . Sell{background:url (". /images/picture. png ") 0-100px no-repeat; height:30px; width:50px; . Buy{background:url (". /images/picture. png ") 0-100px no-repeat; height:30px; width:50px;

After improvement

. Login,.reg,.sell,.buy{background:url ("picture. png") No-repeat} <1

. Login{background-position:0 -100px;

. reg{background-position:0 -100px;

. sell{background-position:0 -100px;

. buy{background-position:0 -100px;

This is a shorthand for CSS to reduce the size of the CSS file.

In order to reduce the number of CSS connections, will be the CSS code directly written in the home page of "style" * * * * * * */style, this situation is suitable for such as Baidu, 163, Taobao this heavyweight.

The usual writing is

<link href= "Css/index.css" rel= "stylesheet" type= "Text/css"/>

...

<link href= "Css/top.css" rel= "stylesheet" type= "Text/css"/>

We can write the shared head style into a common.css, and then in the index.css inside the home page

  

@import url ("Common.css");

Note: Do not @import URLs ("Common.css") and import @import URLs ("Common1.css");

Because the home page will be loaded common.css saved, when the second user access directly calls the local cache, thereby speeding up the speed.

Third, the site's JS optimization

In order to facilitate management, a lot of people in the writing JS, as long as the ads will use JS instead, the code is as follows;

Text Connection JS Call:

  

&lt;script language= "JavaScript" &gt;document.write ("&lt;a href= ' # ' target= ' _blank ' &gt; affiliate Advertising Link &lt;/a&gt;");&lt; /script&gt;

Text call to a picture link:

  

&lt;script language= the "javascript" &gt;document.write ("&lt;a href= ' # ' target= ' _blank '" &gt;&lt;img ')-src= ' abc.jpg ' &gt;&lt;/a&gt; ");&lt;/script&gt;

Because JS will originally 1 lines of code into three, four lines, added some unnecessary code, but also increased the download request.

Summary: This is for short-term high flow, such as high flow stability long rise, income increased, you can buy a server to put Css,js, pictures of these large files to the new server. This is a way to do a radical effect.

These are just some of my experience, I hope to provide help for the general webmaster, write is not good, I hope you understand.

This article by the excellent second-hand car net http://www.uu2car.com original, reprint please note name source.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.