`

[插件] 静态资源插件

阅读更多

Static Resources Plugin

When you are serving images and other binary files you usually want to do this via a high performance native httpd such as Apache. This means you need (ideally) to store them in a location outside of the webapplication, but you also need to be able to access them locally while you are developing your grails application.

This plugin makes it easy. Using it means:

  • You no longer have to upload all your, perhaps very large, static content when you update your web application - i.e. smaller WAR sizes
  • Your static resources can be served faster by a highly optimized native httpd such as Apache
  • Your static resources still appear as part of your local Grails project filestructure
  • Your static resources can be updated on the live server without redeploying your WAR or editing the expanded WAR directory
  • Behaviour of your application is identical on server or locally, with no special effort from you (apart from setting up your live server's httpd to serve /resources/ alias)

Install the plugin into your project. Then simply make any links to resources that are to be served "externally" use the <g:resourceLinkTo dir="xxx" file="yyyy"/> tag.

Put your static resources into <yourproject>/static/

Run the application and your resources will be served by another mini httpd on port 8088, separate from the Grails Jetty. It serves everything under ./static.

To deploy to a live server, upload all your content from ./static (Which is not bundled in your WAR) to your httpd's filesystem.

When running on a live server, the plugin automatically prepends /resources/ to all resource links. You may therefore need to add a SetEnvIf line to exclude /resources/ from your mod_jk mappings, if you have your web-application mounted to /

If you don't have your webapplication mounted to /

you can either copy your ./static content to your httpd's document tree under /resources/ or to somewhere else and have an alias for /resources point to it.

You may also add a configuration option to change the location of the production files. The configuration key is: staticresources.production.resource.prefix

Marc Palmer marc AT anyware.co.uk

Get the ZIP file or source from: http://svn.grails-plugins.codehaus.org/browse/grails-plugins/grails-staticresources

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics