Search engine optimization Url automatically submit ideas script

Search engine automatically Url link to submit scripts

[!!!] to be optimized transformation, through the analysis process automatically submit scripts to extract commit logic, achieve analog input Sitemap automatic robot after submission, rendering submit business code only, or analog request request, and without rendering real site pages, reducing resource utilization and business complexity, increase performance and efficiency of the automatic submission.

Baidu automatic submission script:

<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>

360 automatically included in the code:

<script>
(function(){
var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?f757a4cfb88d6de03df10aaac75ebdc5":"https://jspassport.ssl.qhmsg.com/11.0.1.js?f757a4cfb88d6de03df10aaac75ebdc5";
document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

[Records] optimization ideas

(JS links Baidu push the code)
as long as you put this code into each page, whenever a user accesses these pages, you will download a 1x1 gif from Baidu through this script while recording page at this moment URL address.
Performance considerations script automatically pushed
through this script, we can see:
1, it first determines the type of the current protocol is https or other types (eg, http, ftp, etc.)
2, and then download the Baidu official of a js file
3 , and then it js file content to generate a script block into the current page
4, the last block will run this script
we can access both js file to view its contents, which is a short line. It would read such a gif.
https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif or http://api.share.baidu.com/s.gif
while window.location.href other information pushed to the Baidu.
Here we can find two questions:
First, is this script will call two Baidu has the resources, which resulted in redundancy, it is not conducive to the page loading speed.
Second, it is that the script will be submitted to the current URL, but the URL will be many dynamic URL, will bring a variety of parameters. Although Baidu reptiles also have their own judgment method, but it certainly adds to its burden.
So, in order to solve these two problems, I consulted a friend Chaiyun Xiang is also the front-end development of large cattle. With the help of Daniel, we have the following improved version.
Baidu index improved version of the script automatically push

The modified script below so long.

<link ref=“canonical” href=“http://www.domain.com” > //在各个页面的Head中定义当前页完整地址

> <script>
>   (function(){
>       var canonicalURL, curProtocol;
>       //Get the <link> tag
>       var x=document.getElementsByTagName("link");
>       //Find the last canonical URL
>       if(x.length > 0){
>           for (i=0;i<x.length;i++){
>               if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
>                   canonicalURL=x[i].href;
>               }
>           }
>       }
>       //Get protocol
>       if (!canonicalURL){
>           curProtocol = window.location.protocol.split(':')[0];
>       }
>       else{
>           curProtocol = canonicalURL.split(':')[0];
>       }
>       //Get current URL if the canonical URL does not exist
>       if (!canonicalURL) canonicalURL = window.location.href;
>       //Assign script content. Replace current URL with the canonical URL
>       !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
> </script>

(Baidu index improved links automatically submit scripts)
in the above figure has been put in a comment, I began to explain the code below.
canonical attribute indicates that the page even if we have one thousand kinds of tricks URL, search engines just look for the value of the href URL given in
the role of this new script is a multi-step view of the canonical URL of the page steps. we know. As a search engine to not let the same page (perhaps already indexed) number of checks you push specific page content.
This is another new script changes directly to the content of the above-mentioned two js took out. Since the two js code is actually static, each time to call and unnecessary. On the other hand, we need to change the value of r, it will change the value of the canonical URL, so this solves the second problem above us.
Finally, a little feelings
automatic push is a very practical approach to its low threshold, easy to deploy, but there are some minor problems. This article is provided a method of automatically pushed to improve the efficiency and effectiveness.
Note that Baidu may update the contents of the two js files at any time, although not updated later after the function does not mean that the line has not been updated, so you need to manually update the code.
Questions about the update, you can use the nginx cache capacity, frequency resolved definition updates

Guess you like

Origin blog.51cto.com/uppower/2462034