重复加载 JSONP 在 Safari、Chrome 中不起作用

发布于 2024-10-09 09:22:05 字数 314 浏览 0 评论 0原文

我正在使用 JSONP 从我的 CDN 加载频繁更新的分数数据。 JSONP 文件通过单个 URL 加载,该 URL 不会因请求而改变。它在 Firefox 和 IE 中工作没有问题,但在 Webkit(特别是 Safari 和 Chrome)中,我看到该文件仅从服务器加载一次;之后,文件及其旧数据只是从这些浏览器的缓存中重新加载。

我可以通过在 URL 末尾抛出一个随机数(或以其他方式使请求唯一)来防止这种行为,但随后我们的 CDN (Akamai) 会简单地转发来自每个用户的请求,我们的源服务器就会崩溃。

有谁知道还有其他方法可以通过 CDN 有效地执行 JSONP 吗?

I'm using JSONP to load frequently updating score data from my CDN. The JSONP file is loaded via a single URL which never changes from request to request. It works without issue in Firefox and IE, but in Webkit (Safari and Chrome specifically), I'm seeing the file only getting loaded off the server once; after that, the file -- and its old data -- is simply reloaded from cache in these browsers.

I can prevent this behaviour by throwing a random number at the end of the URL (or otherwise making the request unique), but then our CDN (Akamai) would simply forward the request from each and every user and our origin servers would melt.

Does anyone know of any other way to do JSONP efficiently with a CDN?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2024-10-16 09:22:05

您的问题是缓存控制:您告诉 Akamai(它告诉您的浏览器)保留文件版本多长时间。您必须提前计算出文件的当前版本有多长,并让您的网络服务器正确设置 Cache-Control 标头。

这是一个复杂的主题,但您的 Akamai 代表可以提供帮助(我的代表可以帮助我)。

Your problem is the Cache-Control: you are telling Akamai (which tells your browser) how long to keep the version of the file. You have to figure out ahead of time how long the current version of the file and have your webserver set the Cache-Control header correctly.

It's a complicated subject, but your Akamai rep can help (mine helped me).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文