Stop Caching Plugins in Development

Hi all!

I’m updating my plugin, Psychart, and have recently updated my locally-hosted Grafana instance to version 10.0.2. I’ve noticed when running npm run dev, my plugin builds correctly in the dist directory. However, localhost does not update with my plugin changes until I clear my browser cache. My conclusion is that Grafana plugins are now being cached in as of version 10. I couldn’t find any breaking changes on this. Normally, I think this would be a great addition, except it is near impossible during plugin development. How can I disable this feature? Please get back to me soon! Thanks.

Hi @ventura no changes were implemented in terms of caching for plugins for newer versions of grafana. Perhaps this is a setting you need to setup in your browser?

If you are using a chromium-based browser (such as google chrome) to develop you can instruct it to disable cache when your dev tools are open.

In your Network tab → Disable cache.

image

In firefox you can find this same option under the network tab too

image

Thank you! I think this fixed it. Good intuition!

For future reference: I upgraded my Grafana instance to version 10.1.1 and got the following error.

Error loading: ventura-psychrometric-panel

I tried to solve the problem using these steps:

  1. I deleted the dist/ folder and completely re-built the plugin with npm run dev
  2. Then, I restarted my Grafana instance. (After restarting, I was still getting the error.)
  3. In the browser settings, I cleared my browser cache (for all time.)
  4. In my Grafana tab > Network, I re-enabled the cache and refreshed.
  5. Then I re-disabled the cache, and now it seemed like my plugin updates after every refresh, but…
  6. As soon as I closed the developer console and refreshed, my plugin did not update.

Here’s the real solution:

As soon as you close the developer console, it “forgets” that you disabled the cache and starts re-caching your plugin again. But as long as you keep the developer console open, it will force the browser to not cache your plugin.

1 Like

Hi @ventura this is an expected browser behaviour and grafana has no influence on this. You must keep the developer tools open for the non cache option to work. Most browsers have an option so if you open a new tab with a tab that has the devtools open, the new tab will also have the devtools open.

@ventura how are you running grafana? using docker? can you share your docker compose file if you do?

No, I am running npm run dev and opening Grafana in my browser.