These are chat archives for canjs/canjs

28th
Jul 2017
Viktor Busko
@Lighttree
Jul 28 2017 14:10

Guys one question regarding caching data.
I have lots of requests to the same url to get different Persons. For example I have a list of "cards" and for each card I have to do 2 requests for persons "author" and "recipient". "Author" is the same most of the time. So I would like to avoid unnecessary calls and cache all persons in...memory or localstorage I don't really care right now.

I see that can.js provides different caching strategies like
https://canjs.com/doc/can-connect/cache-requests/cache-requests.html

and this seems like what I need. But when I try to apply this, it doesn't work. I have identical requests except Authorization header, because by back-end design I have to send request with different tokens. Is this might prevent request caching ?

Kevin Phillips
@phillipskevin
Jul 28 2017 14:13
no, it shouldn't
that's the easiest way to set up fall-through caching
if you're just using cache-requests directly, make sure your algebra is set up
that's my guess as to what is making it not understand the two requests are the same
Viktor Busko
@Lighttree
Jul 28 2017 14:17
As I got fall-through cache taking data from local-storage but still doing the request right ? I would like to avoid requests itself so I need cache-requests too
Kevin Phillips
@phillipskevin
Jul 28 2017 14:18
yeah, that makes sense
Viktor Busko
@Lighttree
Jul 28 2017 14:18

that's my guess as to what is making it not understand the two requests are the same

It understands because I see that persons are added in localStorage

Viktor Busko
@Lighttree
Jul 28 2017 14:34
https://canjs.com/doc/can-connect/cache-requests/cache-requests.html
Should this work for single items ? Or it designed to work with lists only ? Because I have lots of single items.
Kevin Phillips
@phillipskevin
Jul 28 2017 14:38
oh, I think it only works for lists
I think it would be possible for it to implement getData also, if you want to submit a proposal
Viktor Busko
@Lighttree
Jul 28 2017 14:41
We just configured 'fall-through-cache' with 'memory-cache' and it works :) doesn't remove requests, but improve performance for end user alot. Cool things.
Kevin Phillips
@phillipskevin
Jul 28 2017 14:48
yeah, it will return the cached data and then make the request
and update the data once the request completes
so you still get the request, but that might be better long term anyway,
if your data could become "real-time" at some point
Frank Lemanschik
@frank-dspeed
Jul 28 2017 15:22
does any one know if we could copy that fast?
i think its nice if we would also have errors by component some how
i think we could maybe do errors by viewModel ?
as the code normal always gets executed inside a viewModel right?
lmagarian
@lmagarian
Jul 28 2017 22:36
I'm trying to follow the example from the Playlist Editor recipe to use jQuery++ for drag/drop events. My events aren't firing. I've tried defining them like this: <span ($dropover)="alert(1)"> in the stash file and like this in a can Component ".element-class dropover": function ( el, ev, drop, drag ) { but in neither case are the events fired. I suspect I'm missing some can package. I have these three: import Component from "can-component/";
import "jquerypp/event/drag/drag";
import "jquerypp/event/drop/drop";
Can anyone point me in the right direction?