sifr3 - 预取不起作用?
我在启用 sifr 3 的网站的加载时间/大小方面遇到问题,并发现在我的应用程序中多次请求字体 swf。 这可以在 firebug 的网络选项卡以及 apache 日志中看到。
在 http://novemberborn.net/flash/prefetching-movies 上有一些预取的说明。 然而这不起作用,预取方法不可用(仍在文档中!)。 我知道预取是自动完成的,但这似乎不起作用。
即使在 sifr 下载包的演示页面中,在浏览器缓存为空的情况下,我也获得了 rockwell.swf 和 cochin.swf 的多次点击! Firefox 3 和 IE7 均适用...
是否有机会进行简单快速的修复?
问候, 西蒙
I am having a problem with the loading times/size of an sifr 3 enabled site, and found out the the font swf is requested several times in my application. This can be seen in the network tab of firebug, as well as in the apache logs.
On http://novemberborn.net/flash/prefetching-movies there are some instructions for prefetching. However that does not work, the prefetch Method is not available (still in the docu!). I understand that prefetching is done automatically, however that does not seem to work.
Even in the demo page of the sifr download package, with an empty browser cache I get several hits for rockwell.swf and cochin.swf! Both with Firefox 3 and IE7...
Any chance for an easy and quick fix?
Greetings,
Simon
从根本上来说,这是浏览器和 Flash 播放器之间的问题。 当 sIFR 将 Flash 影片插入页面时,浏览器会使用 Flash 影片的路径初始化 Flash 插件。 如果本地缓存中还没有该电影,则会向服务器请求该电影。 由于电影是在几毫秒内插入的,这意味着对每个插入的电影都会发出请求。
sIFR 尝试通过预取 Flash 影片来防止这种情况发生。 它根据会话 cookie 在每个浏览器会话中执行此操作。 这只会触发对电影文件的请求,并且希望在替换开始时该文件已在缓存中。 因此,尽早加载 sIFR JavaScript 代码并通过将 Flash 影片传递给
sIFR.activate()
方法来正确激活 sIFR 非常重要。根据我的经验,可靠地测试此过程的唯一方法是清除浏览器缓存,关闭所有浏览器实例(以摆脱会话 cookie),然后打开浏览器并直接进入您要测试的页面。 我发现浏览器中的活动监视器不可靠,因此要么通过 HTTP 代理进行检查,要么通过服务器日志进行检查。
我可以做的一项剩余改进是尝试检测预取的进度,并推迟替换元素,直到预取完成。
Fundamentally, this is an issue between the browser and the Flash player. As sIFR inserts the Flash movies into the page, the browser initializes the Flash plugin with the path to the Flash movie. If the movie is not yet in a local cache, it's requested from the server. Since the movies are inserted within a few milliseconds, this would mean that a request is made for each inserted movie.
sIFR tries to prevent this by prefetching the Flash movies. It does this ones per browser session, based on a session cookie. This merely fires off a request for the movie file, and hopefully that file is in the cache by the time replacement starts. Therefore its important to load the sIFR JavaScript code as early as possible, and to activate sIFR properly by passing the Flash movies to the
sIFR.activate()
method.In my experience the only way to reliably test this process is clearing browser cache, closing all browser instances (to get rid of the session cookie), then opening the browser and going straight to the page you want to test. I don't find the activity monitors within browsers reliable, so either check through an HTTP proxy or the server logs.
The one remaining improvement I could make is to try and detect the progress of the prefetch, and hold off on replacing elements until the prefetch is complete.