Bypass fall-through cache on can-connect model

The fall-through cache on superMaps is very useful for using models in stache templates, however there are times when we have javascript code that needs to get data via getList and we won’t want to get stale data.

For example

Order.getList({status: 'pending'}).then(function(orders) {

});

is going to return us a stale list of pending orders, some of which may no longer be pending. Is there a way or best practice for making sure that we get the data from the server and not the cache?

yes, don’t use supermap. Use https://canjs.com/doc/can-connect/can/base-map/base-map.html instead. It’s like supermap, but without the fall through cache.

Btw, you can assemble your own connections by mixing different behaviors.

I was wondering if there was a way to have the best of both worlds. I.E. having the fall through cache available in stache templates, but with the ability to bypass the cache when required.

how would you know when it’s required?

You could create your own behavior that wraps the localStorage behavior to say there’s nothing in it if the last time it has been updated has exceeded some amount of time.

https://canjs.com/doc/can-connect/data/localstorage-cache/localstorage-cache.html