为什么SAPUI5多次加载类似的片段? [英] Why SAPUI5 loads similar fragment several times?

查看:106
本文介绍了为什么SAPUI5多次加载类似的片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML片段,并在XML视图的多个地方使用它。

 < IconTabFilter text = ABC key = 1 icon = sap-icon:// alphabetical-order > 
< content>
<表id = table1 width = auto items = {path:'/ ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{{path: 'Surname',operator:'StartsWith',value1:'A'},{path:'Surname',operator:'StartsWith',value1:'B'},{path:'Surname',operator:'StartsWith', value1:'C'}]} noDataText = {worklistView> / tableNoDataText} busyIndi​​catorDelay = {worklistView> / tableBusyDelay} growth = true growthScrollToLoad = true updateFinished = onUpdateFinished>
< headerToolbar>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesHeader type = XML />
< / headerToolbar>
< columns>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesColumns type = XML />
< / columns>
< items>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesRows type = XML />
< / items>
< / Table>
< / content>
< / IconTabFilter>
< IconTabSeparator icon = sap-icon:// process />
< IconTabFilter text = DEF key = 2 icon = sap-icon:// alphabetical-order>
< content>
<表id = table2 width = auto items = {path:'/ ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{{path: 'Surname',operator:'StartsWith',value1:'D'},{path:'Surname',operator:'StartsWith',value1:'E'},{path:'Surname',operator:'StartsWith', value1:'F'}]} noDataText = {worklistView> / tableNoDataText} busyIndi​​catorDelay = {worklistView> / tableBusyDelay} growth = true growthScrollToLoad = true updateFinished = onUpdateFinished>
< headerToolbar>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesHeader type = XML />
< / headerToolbar>
< columns>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesColumns type = XML />
< / columns>
< items>
< core:FragmentfragmentName = de.cimt.cimply.AddressBook.view.worklist.tablesRows type = XML />
< / items>
< / Table>
< / content>
< / IconTabFilter>

但是视图加载的时间太长,尤其是在WEBIDE中。



原因是它多次加载相似的片段文件。这是一个证据:





问题是如何提高性能?



我不想重复代码,我需要把代码的那一部分片段中,但我希望浏览器不会多次加载相同的文件。

解决方案

无需更改您的文件在这种情况下的代码。 SAP Web IDE / SCP利用



如您所见,片段(和其他资源)是从磁盘缓存加载的,而不是一次又一次地重新获取它们。



此外,如果应用程序是为最终生产环境捆绑的,则这些碎片甚至不会被多次请求,因为它们通常已经包含在捆绑的文件中(例如 Component-preload.js )。





I have an XML fragment and use it in several places in an XML view.

<IconTabFilter text="ABC" key="1" icon="sap-icon://alphabetical-order">
    <content>
        <Table id="table1" width="auto" items="{path:'/ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{path:'Surname',operator:'StartsWith',value1:'A'},{path:'Surname',operator:'StartsWith',value1:'B'},{path:'Surname',operator:'StartsWith',value1:'C'}]}" noDataText=" {worklistView>/tableNoDataText}" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true" updateFinished="onUpdateFinished">
            <headerToolbar>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesHeader" type="XML"/>
            </headerToolbar>
            <columns>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesColumns" type="XML"/>
            </columns>
            <items>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesRows" type="XML"/>
            </items>
        </Table>
    </content>
</IconTabFilter>
<IconTabSeparator icon="sap-icon://process"/>
<IconTabFilter text="DEF" key="2" icon="sap-icon://alphabetical-order">
    <content>
        <Table id="table2" width="auto" items="{path:'/ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{path:'Surname',operator:'StartsWith',value1:'D'},{path:'Surname',operator:'StartsWith',value1:'E'},{path:'Surname',operator:'StartsWith',value1:'F'}]}" noDataText="{worklistView>/tableNoDataText}" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true" updateFinished="onUpdateFinished">
            <headerToolbar>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesHeader" type="XML"/>
            </headerToolbar>
            <columns>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesColumns" type="XML"/>
            </columns>
            <items>
                <core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesRows" type="XML"/>
            </items>
        </Table>
    </content>
</IconTabFilter>

But the view takes too long to load, especially in WEBIDE.

The reason is it loads similar fragment files several times. Here is an evidence:

The question is how can I improve the performance?

I don't want to repeat the code and I need to put that part of the code in a fragment, but I expected my browser to not load the same file several times.

解决方案

There is no need to change your code in that case. SAP Web IDE / SCP leverages App Cache Buster concept out of the box, which fetches application resources (e.g. fragments) from the browser cache as long as those resources were not altered before.

See the sample screenshot below:

Given

  • Code:

    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    <core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
    

  • URL attribute sap-ui-appCacheBuster=... which Web IDE automatically appends on app launch (describes where sap-ui-cachebuster-info.json is located)
  • If the devtool is open: Disable cache Unchecked <-- probably that was still activated in your case

Result

As you can see, fragments (and other resources) are loaded fron the disk cache instead of re-fetching them again and again.

Additionally, if the application is bundled for the final production environment, those fragments won't be even requested multiple times as they're typically already included in the bundled file (e.g. Component-preload.js).


这篇关于为什么SAPUI5多次加载类似的片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆