问题标签 [google-cdn]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
476 浏览

jquery - 我应该合并所有的 CDN 脚本还是单独加载流行的脚本?

这里有一个类似的问题,但我的问题特定脚本方面更具体一些,无论如何我都会使用 CDN。

Jsdeliver 允许您将多个脚本合二为一。

例如,我可以像这样添加 jquery 和 jquery migrate: https://cdn.jsdelivr.net/g/jquery@1.11.3,jquery.migrate@1.3.0

从速度的角度来看,单独加载广泛使用的脚本是否更好,因为即使它们来自不同的域,它也可能已经被缓存?或者即使确定它们不会被缓存,也可以将它们组合在同一个 CDN 域中?

这个问题可能没有明确的答案...

Google 的 jQuery 使用最多,所以即使我使用与其他脚本不同的 cdn,从 Google 加载它总是更聪明吗?

Pagespeed 洞察力告诉您从一个 url 一起加载脚本,但对我来说,这似乎有可能:

可能仍然比这更好,因为 jquery 可能已经被缓存:

0 投票
2 回答
198 浏览

angularjs - 有没有 ngComponentRouter CDN?

是否有任何来自谷歌的官方 CDN 具有 ngComponentRouter,我无法在任何地方找到它。

0 投票
2 回答
343 浏览

amp-html - Google AMP Cache 是否保证不会造成链接失效?

Google AMP Cache是一项通过以下格式的 URL 提供 AMP 页面缓存版本的服务:

现场演示: 原始 URLGoogle AMP Cache 上的兑现版本

Google 是否保证此服务将(实际上)永远可用?(我在文档和常见问题解答中没有发现任何提及。)我问是因为如果谷歌要关闭它,那会造成相当多的链接失效,因为各方(包括最终用户)可能会依赖在这些 AMP 缓存 URL 上。


推特上的相关讨论


更新:我已经用真实的 URL 更新了这个例子。

0 投票
1 回答
4772 浏览

css - 用于外部 CSS 的 @import 字体 VS HTML 链接

我有一个使用 Google CDN 中的两种字体的网站。

第一个是在主 CSS 文件开头从 Google CDN 导入的 @imported,如下所示:

第二种字体直接链接到来自 Google CDN 的 HTML 中,如下所示:

任何人都可以解释每种方法对性能的影响以及为什么要选择其中一种方法吗?

0 投票
2 回答
440 浏览

javascript - 最新的 Google Angular CDN 不起作用

以下是使用 google angular js cdn 的演示页面:

我使用了最新的 google angular js cdn。

它给出了一系列错误,如下所示:

但是,当我将 angular 的版本更改为1.0.1. 页面显示正确。

新版本有变化吗?

0 投票
3 回答
9629 浏览

google-maps - //maps.google.com/maps/api/js 的子资源完整性值

我在哪里可以找到脚本 //maps.google.com/maps/api/js 的子资源完整性值?

例如:

0 投票
1 回答
478 浏览

angularjs - 如何配置 express.static 从谷歌云 CDN 中提取静态内容?

我正在尝试在 Google 云应用引擎中托管一个 Angular 应用。使用 express 来提供内容和静态应该来自 google CDN。

Dist 被构建并交付到 CDN。CDN 存储桶也已共享。

我把它作为一个基本的快速应用程序从本地 ./dist 文件夹中提供静态内容。如何配置它以对抗 CDN?

感谢任何指针。

谢谢 !!

0 投票
1 回答
452 浏览

google-compute-engine - Google Load-Balancing CDN

I am using the Google Load-Balancer with the CDN option enabled.

When I setup the Backend Configuration for the load-balancer, I setup a backend with instances in US-Central, US-West and US-East.

Everything is working great, except all traffic is being routed only to the US-West backend service.

Does the load-balancer option route traffic to the closest backend service?

I see that there is an advanced menu in the load balancer for creating forwarding rules, target proxies and more.

Is there something I need to do to make my load-balancer load closest to client?

If they are in Florida and the CDN does not have the file, they get routed to the US-East VM Instance?

If that is not possible, it seems like having only an US-Central server would better than having US-Central, US-East and US-West? That way East Coast misses are not going to the West Coast to get the file. Everything will pull from the central location.

enter image description here

Unless there is a way to route traffic from the load-balancer to the closest VM instance, it seems as if the only solution would be to create different load balancers with the CDN enabled and use DNS routing to point to the CDN pool that is closest.

That setup would use 3 different CDN ip address's, 3 Compute Engine ip address's and dns latency or location routing. If they are in Florida, route them to the Google Load Balancer CDN in the east coast.

I'm not sure that would be a good solution on top of the Anycast ip routing. It seems like overkill.

Thank you for listening and any help or guidance would be appreciated.

"By default, to distribute traffic to instances, Google Compute Engine picks an instance based on a hash of the source IP and port and the destination IP and port."

Similar question: Google compute engine load balancing not routing properly Except all traffic in a live environment is all going to the same VM instance.

I am using the Google CDN Frontend Anycast ip address.


I think Elving is right and there may be a mis-configuration. Here is a screen shot of the VM instances in the Google Cloud. It says the two instances aren't in use.

Here is another picture of the Instances Groups. I don't see a clear way to make the instances attached to the instance groups.

enter image description here

enter image description here

0 投票
1 回答
5072 浏览

google-kubernetes-engine - 如何为 GKE 服务创建 Google CDN

我已经在 GKE (kubernetes) 上部署了一个 wordpress 站点,我可以像 mysite.test.com 这样从 Internet 访问我的站点,并且工作起来就像一个魅力。现在想用谷歌CDN来加速访问。我尝试过使用 Ingress 资源,但我想使用 Google Console 的 Networking 选项卡上的 Load Balancing 来实现。我需要采取哪些步骤?

0 投票
1 回答
785 浏览

html - CDNed AMP 页面的正确链接 URL

我使移动网站的静态部分与放大器兼容,但我不确定除此之外是否还有其他必要的步骤。

特别是,通过将网站内部链接重写到页面的 CDN URL 来强制用户通过 Google 的 CDN 加载页面是否可以(或者甚至有必要?)?即类似的东西<a href="http_s_://cdn.ampproject.org/c/s/example.net/b.html">...</a>?或者这会以某种方式扰乱谷歌的爬虫?

事实上,我已经简单地尝试过了,但是即使当前页面是通过其 CDN URL 加载的,当单击链接时页面仍然会在新选项卡中打开。这是故意的吗?我尝试使用 target="_top",但显然这对于​​兼容的 amp-html 是不允许的。

那么这里推荐的解决方案是什么?