I have a primary layout file that is utilized in the majority of views. Within this layout, I am integrating a module using the Grails resources plugin.
<r:require module="core"/>
The definition of modules can be found in the conf/ApplicationResources.groovy file:
modules = {
core {
resource url: '/css/main.css'
resource url: 'js/application.js'
}
}
However, there seems to be an issue. Whenever I make changes to the main.css file and rebuild the application, the modification does not appear in the browser. It only updates if I view the source and manually refresh the css file link. This caching behavior of the browser is causing complications. I attempted to include a version parameter in the code like this:
modules = {
core {
resource url: '/css/main.css?version=2'
resource url: 'js/application.js'
}
}
Unfortunately, even this approach proved ineffective. Upon inspecting the generated css link tag, it becomes clear why the version method was unsuccessful:
<link href="/app/static/bundle-bundle_core_head.css" type="text/css" rel="stylesheet" media="screen, projection" />
Consequently, adding a version number did not yield the desired results. As a last resort, I resorted to:
<link href="/app/static/bundle-bundle_core_head.css?version=2" type="text/css" rel="stylesheet" media="screen, projection" />
This led to the update of the css file, but this solution feels like a temporary workaround rather than a permanent fix.
Hence, my inquiry pertains to any possible methods for automatically updating the css file when modifications are made while employing the Grails resources plugin.
Resources Plugin
The version of Grails in use is 2.2 with the resources plugin version set at 1.1.6.