I've created an application that is serving some static files, however while I'm development it's really annoying that the server caches the static content instead of returning what's on disk. And yes, using the development mode with ./gradlew run --continuous
IS sub-optimal.
I would like to know if there's a property, configuration or something that I can do to disable static content caching so that in my development profile I can set it.
As discussed int he comments of the other answer, using netty.responses.file.cache-seconds
and similar properties doesn't work 'cause that only controls the browser cache.
The problem is that when you're using ./gradlew run --continuous
and you have your micronaut.router.static-resources.my-resources.paths
set to something like classpath:public/
, what will happen is that micronaut, of course, will read from the classpath, which gets changed only when the build is run. In order for you take your current development version without having to rebuild your application, you should use something like:
micronaut:
router:
static-resources:
shared-static:
enabled: true
mapping: /public/**
paths:
- file:src/main/resources/public
By doing this in your development profile, you'll always get the latest version rendered by micronaut.
Should the browser cache also be a problem, then you should combine this answer with https://stackoverflow.com/a/60763922/3073044.