简体   繁体   English

Ember.js应用程序为何加载两次?

[英]Ember.js application why loads twice?

I'm developing an Ember.js application on my own and while started to track how the scripts do loading, just noticed that if the ember.js core and the handlebars.js are minified in the same file, my application.js will load twice. 我正在自行开发一个Ember.js应用程序,同时开始跟踪脚本的加载方式,只是注意到,如果将ember.js核心和handlebars.js缩小到同一文件中,则将加载我的application.js两次。

Why? 为什么?

这是有关网络面板的图片(Chrome,wow64)

Is it a strange behaviour of the ember.js and it loads only 'virtually twice' or loads twice for real? ember.js的行为是否奇怪,它仅“虚拟加载两次”还是实际加载两次?

AngularJS was the same but there I got the answer on this behaviour that it's just 'virtual' that means the js wont load again but before angular could initialize it has to tell the browser that 'I have been loaded' and it only could to this in that way. AngularJS是一样的,但是我对这种行为的回答是,它只是“虚拟的”,这意味着js不会再次加载,但是在angular可以初始化之前,它必须告诉浏览器“我已经加载了”,并且只能这样做以这种方式。

So is this the same way? 这是同样的方式吗?

Thanks in advance for answers, Have a good day! 在此先感谢您的答复, 祝您有美好的一天!

This has nothing to do with Ember.js (or Angular, for that matter). 这与Ember.js(或Angular)无关。 This is just the way HTTP works. 这就是HTTP的工作方式。 Your browser is attempting to load a resource that it has already loaded with a If-Modified-Since header or some other header that makes the GET request "conditional". 您的浏览器正在尝试使用If-Modified-Since标头或其他使GET请求成为“条件”标头的标头来加载已经加载的资源。 (See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html ) (请参阅http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

If you notice in your network display, the HTTP response (status) is 304, which means "Not modified"- so there is no transfer of content. 如果您在网络显示中注意到,则HTTP响应(状态)为304,表示“未修改”,因此没有内容传输。 However, the request/response cycle does cost some time, so you should probably look to see why you are requesting the same resource twice... 但是,请求/响应周期确实要花费一些时间,因此您可能应该看看为什么要两次请求相同的资源...

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

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