Bokeh experts,
We are trying to use Bokeh with Flask to deliver pages with graphics through Apache2 using the bokeh.embed.components function. We are experiencing drastic slowness on the page. Digging into the logs we found that the page is sending 1/2 to 1 meg of data every time it loads, the vast majority of this data coming from the bokeh javascript files. Examining the page source we found that not only are we telling the browser to download the scripts, we are also sending the Bokeh scripts every time. Here’s a look at our page’s html:
<html lang="en" >
<head>
...
<!-- Bokeh includes -->
<script src="/static/scripts/bokeh-2.0.2.min.js" crossorigin="anonymous"></script>
<script src="/static/scripts/bokeh-widgets-2.0.2.min.js" crossorigin="anonymous"></script>
<script src="/static/scripts/bokeh-tables-2.0.2.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
/* BEGIN bokeh.min.js */
...
</script>
<script type="text/javascript">
/* BEGIN bokeh-widgets.min.js */
...
</script>
<script type="text/javascript">
/* BEGIN bokeh-tables.min.js */
...
</script>
...
</head>
We have also tried importing bokeh.resources.INLINE to call the render_js() and render_css() functions instead of using the “bokeh…min.js” files, and there is no discernible difference between application load times. The json data used to create our plots is generally between 200-400 kb in size and isn’t appreciably contributing to the application loading times.
We must be doing something really wrong but we can’t figure out why.
- Why isn’t the browser caching the javascript? We can’t find them cached anywhere and have used multiple browsers on multiple OS’s.
- Why is our code sending all of them every time?
Any help will be greatly appreciated every time we load the page!
Versions:
Server: Ubuntu 18.04.5 LTS
Apache: Apache/2.4.29
Python: 3.6.9
Flask: 1.1.2
Werkzeug: 1.0.1
Bokeh: 2.0.2
Thanks,
Brad & Bill