I am using grails resources plugin. On client I am using require.js to fetch js.
my require.js config -
baseUrl: '/js/lib',
With resources plugin enabled -
So I disabled cached-resources plugin using -
grails.resources.mappers.hashandcache.excludes = ['**/*.js']
and new require.js config -
baseUrl: '/static/js/lib',
urlArgs: "bust=" + application_version,
Removing cached-resources solved redirect issue but also removed the expires header which was being set for js files causing browsers to not cache js files at all.
How can I only disable the name hashing in cached-resources and keep the expires headers it sets. Otherwise, are there any plugins for Grails I can use to set these headers and they work well with Resources plugin.
I am using Tomcat and Haproxy to serve content.
I think best solution is to put the hashed js file name in require definition, not the original clear name.
You can echo the hashed name using the resource external tag
<r:external uri="js/custom.js"/>
<script type="text/javascript">
var urlOfCSSToLoadInJSCode = '${r.external(uri:"css/custom.css").encodeAsJavaScript()}';
</script>
<r:external uri="icons/favicon.ico"/>