Open muescha opened 11 years ago
As a reminder: https://plus.google.com/108518148617591250391/posts/csEgn2iuioy
I LOVE this idea! I'm actually amazed we never thought about it before... I know we want this to be a core feature since it's a pretty common scenario when creating a web application. I'm just not sure how we might deal with it.
Please also remind that this is a pure performance debate, the linked file won't be loaded twice tru the network, browser's cache would do its job. What we are talking about here is to make Emy smarter by not overwrite the exact same view(s). If the linked file includes a hundred views, that might be noticeable, but in most cases, it's a pure battery saving / performance improvement (which remain important, specially for mobile devices!).
Thinking about it, i might be a good idea not to deal with this on the link side but on the linked view side. Here is what i have in mind:
<a>
element stays untouched, with href="externals.html like today.But when Emy loads this externals.html and set its first view as the one to show, Emy checks this view node for a data-cache="true" attribute. If so, it changes the tapped/clicked link href attribute value to #view.id.
I like this mechanism better since it's 100% compatible with existing code, and could be added easily later. It also leaves this to developer's choice since a GET parameter can tell the server to generate external view(s) file with this data-cache attribute or not.
ex 1: externals.php generates <section id="view" data-title="My view" data-cache="true">
ex 2: externals.php?dontcache=1 generates <section id="view" data-title="My view">
Agree too, we might want to make this process default or not. I propose emy.ajaxCacheHandler
default as false to match this first process. Changing it to true
would then make this for all externally loaded views, except if the loaded view as data-cache="false"
.
This would actually fit both cases, with just one since attribute.
proposal:
data cache setting
a link can have a data tag
data-cache
which can havetrue
orfalse
<a href="item/1" data-cache="true">item 1</a>
then the emy library replaces the href link to the appended content
id setting
if you need special id then you can set it with
<a href="item/1" data-cache="true" data-cache-id="item-1">item 1</a>
default data cache setting
you can set a default cache on the body tag like
data-cache-default="true"