简体   繁体   English

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

[英]Repeated loading of JSONP doesn't work in Safari, Chrome

I'm using JSONP to load frequently updating score data from my CDN. 我正在使用JSONP从CDN加载频繁更新的乐谱数据。 The JSONP file is loaded via a single URL which never changes from request to request. JSONP文件通过单个URL加载,该URL从一个请求到另一个请求都不会改变。 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; 在Firefox和IE中,它可以正常工作,但是在Webkit(特别是Safari和Chrome)中,我看到文件仅从服务器上加载了一次; 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. 我可以通过在URL末尾抛出一个随机数(或使请求唯一)来防止这种行为,但是我们的CDN(Akamai)会简单地转发来自每个用户的请求,而我们的原始服务器将会崩溃。

Does anyone know of any other way to do JSONP efficiently with a CDN? 有谁知道使用CDN有效地执行JSONP的其他方法吗?

Your problem is the Cache-Control: you are telling Akamai (which tells your browser) how long to keep the version of the file. 您的问题是Cache-Control:您正在告诉Akamai(它告诉您的浏览器)将文件版本保留多长时间。 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. 您必须提前弄清楚该文件当前版本的时间,并让您的网络服务器正确设置Cache-Control标头。

It's a complicated subject, but your Akamai rep can help (mine helped me). 这是一个复杂的主题,但是您的Akamai代表可以提供帮助(我的帮助了我)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM