Plugins You can find out about all the publicly available Grails plugins.

Resources First Plugin

  • Tags: performance, utility
  • Latest: 0.3
  • Last Updated: 02 March 2009
  • Grails version: 1.1-RC1 > *
  • Authors: null
0 vote
compile "org.grails.plugins:resources-first:0.3"




Resources First Plugin

In production environment you usually want to have your static resources be served by a native web server (Apache httpd comes to mind). This setup will most likely not be available on for your development box. As jetty does serve resources that are not matched by the UrlMappings this is no problem as long as they "fall through". They just get served from the WEB-INF directory. As soon as you have a "match-all" clause in your mappings though - you are in trouble. Now you would have to map and handle the resources through a Grails controller.

With the "Resource First" plugin you can give higher priority to certain URI that start with a prefix. You can e.g. route all requests starting with "/img/" directly to the jetty default servlet, by-passing the Grails stack completely.

The reasoning behind this plugin is very similar to the Static Resources Plugin. Differences are:

  • It uses the same jetty. No need to start up another web server.
  • You don't have to use a taglib to wrap URLs to the final location.
  • The resources are still included in your WAR.


Run: grails install-plugin resources-first


Then edit your Config.groovy. Just define what should be re-routed directly to the 'default' servlet

resourcesFirst { map = [ '/images', '/css' ] }
resourcesFirst.servlet = 'default'

Fire up your application as usual and the resources should be served directly. No matter what you do in the UrlMappings file.