0

I have a very big cache problem in my app. See this SPA (Single-page app) load always from cache

In summary I have a view with an iconTabBar https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.IconTabBar/code.

For each tab I have an IconTabFilter fragment in two version: display and change.

In onInit function I load all display IconTabFilter fragments and when the user want switch to change mode, he press the button, call removeAllItems; function and load the new set of new tabs (change fragments).

The problem is that the fragments loaded in onInit function have Cache-Control: max-age=0 in the HTTP call, instead the call for fragments called after (outside onInit) not have Cache-Control: max-age=0 .

In this mode all change fragment that I retrieve after the first page loading are loaded from cache...

I solve the problem loading all fragmens (display and change) in onInit, but I don't know if this is the right way because I might not want to open the change tabs, and in this case I have loaded them uselessly.

I think that I must load a fragment only when I need it!

Community
  • 1
  • 1
padibro
  • 1,324
  • 10
  • 56
  • 95

1 Answers1

2

Your last sentence is the answer. If your app has two dedicated states it makes sense to load the change related fragments if the user switches to change state.

There might be other optimizations like lazy loading of the content of IcontTabFilters or setting the visibility of IconTabFilters depending on the change state. But for this an example would required.

matbtt
  • 4,230
  • 19
  • 26