eReuse / DeviceHubClient

GNU Affero General Public License v3.0
6 stars 2 forks source link

UI takes long time to update after operations #28

Closed forste closed 4 years ago

forste commented 4 years ago

With browser cache active, as is the default case, UI is not updated after operations properly such as create new lot, change lot name, add devices to lot, initiate transfer, etc.

Environment Devicehub client - latest tested commit: https://github.com/eReuse/DeviceHubClient/commit/d704572fd2d59e437210cacf9e48d72c0009c01f Devicehub server - latest tested commit: https://github.com/eReuse/devicehub-teal/commit/dfb518068ddf6223c5d3245925fdeaa81ad49045

forste commented 4 years ago

This happens because API requests are redirected to the browser cache instead of sent to the server, and therefore outdated data is returned and displayed

I've tried to disable the client cache in two different ways

forste commented 4 years ago

I found a project on github with a similar issue https://github.com/jupyterhub/binderhub/issues/315

they resolved it, to change the server configuration to allow the client setting the cache-control header https://github.com/jupyterhub/binderhub/pull/641

fedjo commented 4 years ago

My two cents,

Searching around backend's code I realized that for specific views a teal decorator named cache is used.

For method find which serves for GET /lots seems to have a timedelta of 5 minutes! Have a look here

Could that be the case for long caching? Is the caching happening in GET /lots ?

forste commented 4 years ago

looks promising!

GET /lots is indeed affected.

Can you disable the cache somehow for GET /lots?

forste commented 4 years ago

I also found the cache for GET /devices here https://github.com/eReuse/devicehub-teal/blob/a36cdfbfe7f73f21180435ace39863132b1c13cd/ereuse_devicehub/resources/device/views.py#L113

GET /devices is also affected by this issue: after adding devices to a lot, sometimes devices are not shown because the GET /devices request is directed to the cache, which returns obsolete data

fedjo commented 4 years ago

Server branch hotfix/rm-cache

forste commented 4 years ago

Tested this commit https://github.com/eReuse/devicehub-teal/commit/61fd9de4774e564c0cd466519bbccdc8506ae8b8 as follows

create new lot

  1. create new lot
  2. refresh
  3. request goes to server (not cache), new lot is displayed correctly

same for editing a lot, and adding devices to a lot

So I mark this as closed & fixed by https://github.com/eReuse/devicehub-teal/commit/61fd9de4774e564c0cd466519bbccdc8506ae8b8