# Easiest way to inform server that a PATCH arrived on the client?

**URL:** <https://discourse.bokeh.org/t/easiest-way-to-inform-server-that-a-patch-arrived-on-the-client/12476>\
**Category:** Community Support\
**Tags:** customjs, server\
**Created:** [June 13, 2025, 7:04pm UTC](https://discourse.bokeh.org/t/easiest-way-to-inform-server-that-a-patch-arrived-on-the-client/12476 "2025-06-13T19:04:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrbigelow](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/hrbigelow/32/5817_2.png) [@hrbigelow](https://discourse.bokeh.org/u/hrbigelow)\
**Post date:** [June 13, 2025, 7:04pm UTC](https://discourse.bokeh.org/t/easiest-way-to-inform-server-that-a-patch-arrived-on-the-client/12476/1 "2025-06-13T19:04:18Z")

</div>

Hi,

I would like for there to be some mechanism for the server to be notified when the last PATCH arrives at the client, so that the server knows not to send another one. Is this possible?

The background is, I have a Bokeh server implementing a `slider.on_change` callback. The idea is to use the slider value to filter which slice of data gets displayed in a plot. It is potentially a lot of data (10k points per slice, and possibly 1000 or more slices) so I chose to do this by holding all of the data in a session server side, and only sending the slice to the client.

Also, I’ve implemented a mechanism to prevent multiple on\_change callbacks to be scheduled. Unfortunately, this alone is not sufficient to prevent a backlog when the slider is dragged. I think this is what’s happening:

1. On the client, the slider is dragged, which emits many “on-change” events
2. The server is fast enough to process each of the on-change events completely before the next one arrives.
3. Each invocation of the server-side on-change handler causes a PATCH to be sent to the client.
4. The PATCH messages start to overlap, causing lag.

Here you can (hopefully) see that when the slider is moved and then left alone, the updates to the plot keep rolling in. I’d like to prevent this behavior.

---

<div class="post-metadata">

**Author:** ![gmerritt123](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/gmerritt123/32/4101_2.png) [@gmerritt123](https://discourse.bokeh.org/u/gmerritt123)\
**Post date:** [June 13, 2025, 7:47pm UTC](https://discourse.bokeh.org/t/easiest-way-to-inform-server-that-a-patch-arrived-on-the-client/12476/2 "2025-06-13T19:47:30Z")

</div>

Couple random thoughts:

1. Have you tried/is it viable to use `value_throttled` property on the slider for the application?

2. I’m not sure how complex your filtering effort is, but if the data “slices” are static, it can be a lot faster/less laggy if you restructure the data sorta as follows:

```auto
data_dict = {'data_slice_0':{'Component 1':[.....]
                                            ,'Component 2':[....]}
                   ,'data_slice_1':{'Component 1':[.....]
                                            ,'Component 2':[....]}
                  ,....etc,
                   }

```

Then the on\_change callback grabs the slider value, and sets the CDS’s data to the appropriate key in data\_dict:

```auto
#where sl is your slider and src is the CDS driving the renderer
sl_dict = {i:v for i,v in enumerate(data_dict.keys} #maps slider value to a key in data_dict
src.data = data_dict[sl_dict[sl.value]]

```

I’m not sure if this will resolve the main issue but just sharing a method I’ve used in the past to reduce lag/computation time.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [September 11, 2025, 7:48pm UTC](https://discourse.bokeh.org/t/easiest-way-to-inform-server-that-a-patch-arrived-on-the-client/12476/3 "2025-09-11T19:48:22Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
