Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that website pages cannot be loaded due to the use of Google CDN

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to solve the problem that website pages cannot be loaded when using Google CDN". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to solve the problem that website pages cannot be loaded due to the use of Google CDN".

A large number of domestic websites use free Google CDN services to load some js and font style libraries to improve the web browsing experience, such as jQuery and Google Fonts. However, at present, most of Google's websites cannot be accessed normally in the mainland, so these libraries that speed up the loading of web pages have become the reason for blocking the loading of websites. In this case, there are not many domestic websites, but foreign websites use these libraries very much. In general, when the Google CDN library is called a limiting factor for web page loading, the browser status bar displays the status of "waiting for a response from ajax.googleapis.com." Or "connecting." Wait for the words.

If you open the console, you can see that Google CDN is indeed blocking the page from loading. If you wait long enough, the browser will eventually give up loading and render a broken web page, which is not good. Here are some solutions from the point of view of web developers and browser users.

For web developers: choose other CDN libraries

Web developers must take this into account, so they should consider abandoning the Google CDN library when designing a website. If most of the visitors are from China, you can consider using Baidu CDN and Sina CDN libraries, which contain very commonly used JS library files. If you have international visitors, you can consider using Microsoft's ASP.NET CDN.

For example, the following is an example of using Microsoft CDN to load jQuery:

JavaScript Code copies content to the clipboard

If you want to use Google Fonts, you can use the proxy CDN provided by 360. In this way, even if you want to use Google Fonts web fonts, the speed of the web page will not be interfered or blocked.

Modify hosts

For users, what should we do if we cannot directly cause the web page we are browsing to discard the Google CDN they are using and thus fail to load? One solution is to modify the hosts. By modifying the hosts to force the CDN domain name to point to the specified IP, these files can be successfully loaded from Google.

It is mentioned that some Google CDN, such as fonts.googleapis.com and fonts.gstatic.com, can be resolved to the IP address of the capital, so if the DNS resolution fails, it is the best and fastest to direct these domain names to the IP of the capital through hosts.

Of course, if Google changes his mind and the server in the capital refuses to provide caching services for these domain names, there will be no way out. As for why Google doesn't just parse all the CDN to the capital, no one knows.

Modifying the hosts is not necessarily a good way, because the speed may be slow, and the hosts may fail.

Use Chrome extension to actively replace with domestic CDN

Some domestic servers can keep the same file as Google CDN for domestic users to load by mirroring or synchronous copying and other methods. We can use a Chrome extension called Replace Google CDN to actively replace the Google CDN in the browsed web page as a domestic alternative server.

The plug-in is written by @ justjavac,Github project address is github.com/justjavac/ReplaceGoogleCDN and the extension address is https://chrome.google.com/webstore/detail/replace-google-cdn/kpampjmfiopfpkkepbllemkibefkiice. Of course, you may need to use some techniques to open the app store before you can install it.

The extension supports replacing the CDN provided by Google CDN for University of Science and Technology of China, supporting the replacement of ajax/fonts.googleapis.com and themes.googleusercontent.com, and supporting HTTPS. I want to thank them here.

After installing this plug-in, browsing any web page with Google CDN will be redirected to this node, so that there will be no blocking.

At this point, I believe you have a deeper understanding of "how to solve the problem that website pages cannot be loaded by using Google CDN". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report