Anonymous1
Anonymous1

Reputation: 3907

Grails - prevent caching of changed resources

Is there a standard way to prevent caching of modified resources in Grails 2.4.4? For instance, I would like to have a gsp containing code such as

<g:javascript src="application.js" />

and have browsers not use a cached version of application.js when I deploy a new version of the web app. Is there a place I can update the version number without modifying the filename itself, for instance? If I modify the filename itself, it messes with my git commit history.

Upvotes: 0

Views: 595

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

You really should take a look at using the Asset Pipeline plugin that is in Grails 2.4+ to manage your assets. It will make sure that browsers cache the asset until it changes for you, among other things. Take a look at the documentation.

Simply moving your asset (js in this case) under the grails-app/assets/javascript folder and converting to assets:javascript instead of g:javascript should get you started.

Upvotes: 1

Related Questions