Closed Piskvor closed 7 years ago
Probably most relevant to https://github.com/hotosm/osm-tasking-manager2/issues/923 instead of 918.
Hey!
I just figured that we never use any server side filtering on the users list, ie. the users.json
is never called with a q
parameter. We always load the complete list of users once for all. The filtering is then done on the client.
We should probably change this.
It looks like At.js
should let us do that pretty easily.
https://github.com/ichord/At.js/wiki/How-to-use-remoteFilter
Also we could probably merge the code in https://github.com/hotosm/osm-tasking-manager2/blob/master/osmtm/views/project.py#L435 and in https://github.com/hotosm/osm-tasking-manager2/blob/master/osmtm/views/user.py#L44. The first one is helpful for the assign to
feature.
Hello :) Anyway, the filtering is not really the crucial part of the PR: in mapathons, I'm seeing requests for /users.json slow down and frustrate users - and with 30+ people clicking around in the tile selection, it might exert a significant load on the server as well.
The essential part is setting the Cache-Control headers: after first load, site becomes two orders of magnitude faster. Magic! ;)
Given how small this change is, and how much it improves user experience, I would be very happy to see this live, while we perhaps explore more sophisticated caching schemes.
I'd like to give this a try and prevent as much requests as possible. I'll come back with a different proposal. FYI the current performance issues are not due to the tasking manager but to an other application running on the same machine. Even though I think that adding a cache mechanism would be really nice.
So, the client-side caching is not going to be merged at all, in favor of server-side caching? Or is there some way I could re-write this in a more general way? (The 10-minute cache freshness might be too long, I admit - I just picked a number that I have considered reasonable)
@Piskvor Have you seen the #934 pull request? With this pull request the users.json
is queried only when needed and is very limited. This means that there's no real need to use some caching. Can you please give it a look?
Aha, I have not seen that, looks far more sensible than "just cache it, done." Closing this one then - aven though client-side caching might be useful, this is not the place.
This keeps the @mentions reasonably current, while reducing this file's load time to ~0 per tile select from the current ~2000 ms - which improves both client-side experience and server-side load. The downside is not autocompleting brand new users (newer than the caching interval) - this seems, to me, as an acceptable tradeoff.