Composite graph + cookie free domains

Optimize access speed through “composite graph” and “cross domain static file server”

http://www.wangchao123.com/2009/07/25/361

Facebook composite graph

Icon composition of Google and face book

Composite graph method

When browsing some large professional websites, we find that a lot of stable UI will use a few composite images to store UI images, and CSS and JS displacement will be used to display them in the foreground. There are several advantages to this:

1. Reduce the number of sending requests, reduce the amount of data post to the server

2. When the mouse passes by and needs to change the picture, there will be no delay to cause the defect in the experience

Cross domain method

Another way to greatly reduce the amount of data sent when accessing is to access images across domain names

The main website of many websites is different from the main domain name and static file server of the picture station

Xiaonei.com xnimg. CN
sina.com sinaimg. CN
yahoo.com yimg. Com

If the static file is accessed by the same domain name, the httpwatch tracking request is as follows:

Almost half or more of the bytes are occupied by the cookie. However, when sending an HTTP request to the server, if it is a static file, it is not necessary to send the request. Therefore, if there are 30 pictures on the page, half of the requested bytes are invalid. Moreover, the request is an upload operation, which is slightly slower than the download operation. However, if the image is accessed across domain names, the cookie will not be brought to the request, because the cookie is matched according to the domain name. It is very necessary to save this part of bandwidth in large websites with high bandwidth and high number of visits. The user experience will be much faster. Therefore, if there are conditions, it is better to apply for a domain name for the static document~

http://www.chinaz.com/Webbiz/Exp/0420111b32010.html

Yslow provides 22 suggestions on how to improve web page efficiency and optimize website performance, one of which is about domain names: use cookie free domains

What are the benefits of using cookie free domains?When the user’s browser sends a static file, such as image and CSS style sheet file, it will send cookies under the same domain name (or secondary domain name) at the same time. However, the website server completely ignores the cookies sent, so these useless cookies waste the website bandwidth and affect the website loading speed and page performance. Yslow suggests that in order to solve this problem, we can use cookie free domains to optimize, so as to improve the efficiency of web pages

use secondary domain names as Cookie free domains

Generally speaking, the so-called cookie free domains are domain names that will not send cookies when the browser sends requests for static content. Yslow prompts that you can apply to register a secondary domain name to store these static images, JS and static CSS files

In the previous pan domain name resolution settings affect the SEO and Google PR value, here refers to the beginning of WWW, such as www.farlee.info The domain name of is actually a secondary domain name. If the main domain name of your website is the domain name at the beginning of WWW, it is feasible to establish a secondary domain name as a cookie free domain to host static pictures, JS and CSS files separately; However, if the main domain name of the website is a relatively short top-level domain name, such as farlee.info without WWW, the method of using the newly created secondary domain name as Cookie free domains is invalid. Because the top-level domain name farlee.info will send cookies to all the requested static file secondary domain name servers

Namely www.farlee.info Abcimg.farlee.info and abcimg.farlee.info are two independent “secondary domain names”, which will not cause domain pollution. Abcimg.farlee.info can be used as Cookie free domain names; However, you need to make some settings, such as the following example of setting the wp-config.php file for wordpress blog

The top-level domain name farlee.info will send the www.farlee.info And abcimg. Farlee. Info), abcimg. Farlee. Info will also be contaminated and cannot be used as a cookie free domain name. The specific reasons are described in the cookie free domains settings of wordpress blog below

use independent domain names as Cookie free domains

So how should blogs using top-level domain names use cookie free domains?The solution is to use a separate domain name. Like Yahoo! Yahoo! It uses the independent domain name ymig.com as Cookie free domains, and Youtube uses the independent domain name ytimg.com

Now it’s very cheap to register a domain name. GoDaddy domain names with the suffix. Com. Info. Org. Net are cheap to buy in the first year, and expensive to renew in the second year. At this time, you can replace them in the second year. Some other domain name registrars are similar

wordpress blog cookie free domains settings

In wordpress blog, if you use the domain name with WWW as the main domain name and other secondary domain names as Cookie free domains, you need to set the scope of the cookie. Open the wp-config.php file and set the cookie_ DOMAIN:

< php? define(‘COOKIE_ DOMAIN’, ‘ www.farlee.info ‘); ?>

So called cookie_ Domain is the opposite of cookie free domains. Take a look at WordPress’s introduction to set cookie domain

the cookies domain set for WordPress can set the domain name in some special cases. For example, the use of secondary domain names to store static content. In order to prevent WordPress cookies from being transmitted when requesting static content on each secondary domain name, we can only set the non static domain name as Cookie domian

The domain set in the cookies for WordPress can be specified for those with unusual domain setups. One reason is if subdomains are used to serve static content. To prevent WordPress cookies from being sent with each request to static content on your subdomain you can set the cookie domain to your non-static domain only.

Set up cookie_ Domain can specify which secondary domain name needs to send cookies, and other domains do not send cookies. So if the main domain name of our website is a top-level domain name, cookie_ Domain must be set to the top-level domain name farlee.info, and the top-level domain name setting will be mapped to each sub domain name, so even adding a secondary domain name as Cookie free domains is invalid. At this time, you can only register a separate top-level domain name

Next, take farleeimg.info as an example to demonstrate the steps of setting cookie free domains in wordpress blog

1. Pictures are stored in a separate cookie free domain name

First, enter the farlee.info website space control panel and add the binding domain name: farlee img.info

Then enter the WordPress management background settings: control panel — settings — miscellaneous — fill in the full URL address of the file http://farleeimg.info/ The settings are as follows:

Upload pictures when publishing articles. The domain name address of the pictures displayed on the front desk is cookie free domains (farlieimg. Info)

If it is to use the map bed (can upload pictures, and then get the picture link address of the website space) is more simple, the picture will be uploaded to the image space website server, when publishing the article will take the picture link address

2. WordPress CSS files and JS files are set to store independent domain names

Like the picture, upload CSS and JS to the space bound with cookie free domain name, and take the link URL address. Then modify the URL of CSS and JS in WordPress theme file

3. WordPress emoticons

The method is the same as above. After uploading, modify the WP includes/formatting.php file. Will

$srcurl = apply_ filters(‘smilies_ src’, “$siteurl/wp-includes/images/smilies/$img”, $img, $siteurl);

Change the red part to the URL link address of the emoticon image uploaded to the website space of cookie free domains

In addition, another website speed improvement proposal of Yslow about cookies is that cookie information is exchanged in HTTP headers transmitted between the website server and the browser. Therefore, the cookie size should be minimized as far as possible, and a single cookie should not exceed 4K

http://www.kmwzjs.com/site/q-view60.html

1. The choice of server environment, it is recommended to use Linux server, the reason for choice: after all, the market of Linux now is mainly in the server field, everyone’s choice is reasonable, followed by open source, if the website develops to a certain level, choose open source or not will determine the fate of the website in the future

2. Nginx is used as the HTTP server, which is developed by the Russians. The Russians are excellent in computer software, including Kaspersky, the world’s first anti-virus software

3. The page is purely static, do not use pseudo static. We all know that if it is a non static page, it needs the server to use certain CPU resources to compile it before it can be displayed, while the static page will be displayed directly. In addition, we must not use pseudo static. Pseudo static is actually a technology produced to cater to the search engine, It will increase the resource consumption of the server, so it should be used with caution when the amount of access is large

4. Load balancing technology, generally speaking, is to put the elements on the web page separately on different servers to share the pressure of a single server, such as a single server for the database, a single server for the static page, a single server for the image, and so on. The specific should depend on the situation. The larger the traffic is, the more detailed the distribution should be, For example, domestic portal websites do this. If you look at their pictures, you can see that the pictures are all referenced in other picture servers by subdomain names or other domain names

5. Database optimization. Most of the world spends on it when many large-scale websites are applied. When the website data becomes larger and the number of visits increases, the database bears the brunt of the problem and becomes the first bottleneck to be solved

Similar Posts: