A while back I was asking about using asset hashes in filenames to help bust CDN caches. For now, I’m avoiding generating the hashes at build time, instead generating them dynamically at runtime. I prototyped something that works.
This works, but uses deprecated
resource
API:
Assets.entries.forEach {
resource(
it.hashedPath, // asset/js/browser-app-af00f73c8693fe418e83b020c04d3e78324a1e7dc5a0dd3784de87f66d9ebf68.js
it.defaultPath // asset/js/browser-app.js
)
}
This does not work, using
staticResources
.
Assets.entries.forEach {
staticResources(
it.hashedPath, // asset/js/browser-app-af00f73c8693fe418e83b020c04d3e78324a1e7dc5a0dd3784de87f66d9ebf68.js
it.basePackage // asset/js
) {
default(it.defaultPath) // asset/js/browser-app.js
}
}
Is there a way to do this better with the
staticResources
or another Ktor API?