I'm using kibana 7.10.2, which includes the latest improvements to the packaging scripts @kbn/plugin-helpers:
to build production 3rd kibana plugins using the new architecture:
We noticed that when launching the plugins in developement mode yarn start --oss that any changed plugin resource will be immediately updated in your browser. That's what you expect of a dev mode. This works as cache-control header is set to must-revalidateand ETag are used to ensure client side JS bundels are uptodate: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
However when deploying to production:
cache-control header is set up 1 year and packaged JS resources keep the same name / url. That means even after restarting kibana server side client's won't see the latest version of a 3rd party plugin.
ETags still require a roundtrip to validate the resources. Therefore the preferred solution would be to enable fingerprinting. Is there any infrastructure available build into kibana to use for that purpose? How do we enable that?
Hi how are these resources imported in the code? Files such as JS files should be imported via webpack so they become part of your plugin bundle(s). That way, the resource URL has a cache-busting random number in the URL. (e.g the 39000 in localhost:5601/39000/bundles/plugin/discover/discover.plugin.js)
Regarding the mentioned discover.plugin.js this file is present flat on the filesystem (apart from .gz and brotli compressed version): /usr/share/kibana/src/plugins/discover/target/public/discover.plugin.js
When this file is accessed the cache busting key gets computed to http://localhost:5601/36136/bundles/plugin/discover/discover.plugin.js
The discover plugin is obviously part of the basic kibana stack. The interesting aspect here is that our own plugin data receives the same cache busting key: http://localhost:5601/36136/bundles/plugin/myplugin/myplugin.plugin.js
Therefore if the ELK stack sticks at a specific version, but the 3rd party plugin get's updated, then the cache busting key stays the same, which leads to a dirty client cache.
If the cache-busting key would be computed based on the underlying data (e.g. hash of data content), then it would immediately work. Therefore: How can we enforce to get the cache busting key updated? Ideally it should be computed based on content. Second option would be plugin name + version. But since the same key used even for ELK core plugins (e.g. discover) updating anything in the 3rd party plugin wouldn't be sufficient.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.