gpt4 book ai didi

javascript - Google Adsense 多次加载脚本

转载 作者:行者123 更新时间:2023-12-04 16:14:43 25 4
gpt4 key购买 nike

我有一个显示 Google Ads 的页面 - 其中三个。广告初始化如下:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

<ins class="adsbygoogle class-resp" style="display:inline-block" data-ad-client="ca-pub-4283524395367264" data-ad-slot="8923673879"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

<ins class="adsbygoogle class-resp" style="display:inline-block" data-ad-client="ca-pub-4283524395367264" data-ad-slot="8923673879"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

<ins class="adsbygoogle class-resp" style="display:inline-block" data-ad-client="ca-pub-4283524395367264" data-ad-slot="8923673879"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

问题是页面大小大得离谱,原因主要是每个广告似乎都需要自己下载以下每个脚本,即每个脚本都下载了 3 次,每个页面加载增加了大约 700kb(对于移动浏览量太大)

http://pagead2.googlesyndication.com/pagead/js/r20150402/r20150224/show_ads_impl.js
http://pagead2.googlesyndication.com/pagead/js/r20150402/r20150224/expansion_embed.js
http://pagead2.googlesyndication.com/pagead/js/r20150402/r20110914/abg.js

有谁知道强制三个广告共享上述三个脚本中每一个的单个下载的方法,或者每个广告都必须下载每个广告自己的副本?

最佳答案

一旦下载了脚本,它就会被缓存(如果缓存头可用),因为脚本的第二个请求是从缓存中加载的,所以它不会浪费任何带宽或不会向域/主机发送任何请求。
我刚刚查了http://pagead2.googlesyndication.com/pagead/js/r20150402/r20150224/show_ads_impl.js

HTTP/1.0 200 OK =>
P3P => policyref="http://www.googleadservices.com/pagead/p3p.xml", CP="NOI DEV PSA PSD IVA IVD OTP OUR OTR IND OTC"
Timing-Allow-Origin => *
Cross-Origin-Resource-Policy => cross-origin
Vary => Accept-Encoding
Date => Sat, 04 Sep 2021 06:08:13 GMT
Expires => Sat, 04 Sep 2021 06:08:13 GMT
Cache-Control => private, max-age=1209600
Content-Type => text/javascript; charset=ISO-8859-1
X-Content-Type-Options => nosniff
Content-Disposition => attachment; filename="f.txt"
Server => cafe
X-XSS-Protection => 0
Accept-Ranges => none
它具有缓存控制 header 。

关于javascript - Google Adsense 多次加载脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29516293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com