Last updated by admin 1 year ago
Last updated by marcpalmer 2 months ago
This plugin leverages the Resources plugin to make static resources browser-cacheable with unique filenames based on their content. It works well together with
zipped-resources pluginThere is no application versioning required as this plugin uses a similar approach to "git". It hashes files and renames them to their hash. So when your resource file contents change, the file names automatically change - no more problems with stale JS or CSS content in your client browsers.
The result is that even if your application version changes between deployments, if some resources did not change in that release,
all your users will still be able to continue using their previous long-term cached file without reloading from your site.
It is zero-hassle static file caching.
Usage
Just install:
grails install-plugin cached-resources
See the documentation for the
resources plugin for how to define your resources.
Commercial Support
Commercial support is available for this and other
Grailsrocks plugins.
Resource mappers
This plugin adds the resource mapper called
hashandcache which you can
include/exclude based on URIs or
individual resources using normal Resources configuration mechanisms.
Configuration
There are mapper-specific Config values supported:
- flatten - Controls whether or not the mapper should flatten directories after creating the unique file names
- shorten - Controls whether or not the mapper should shorten the generated hashed file names using base62 encoding (yes that's 62 not 64).
You set these using standard per-mapper
config mechanisms supplied by Resources.
Details
Each file is hashes using SHA-256. Using the resources plugin, it is able to rename the file and change the URL generated when your application links to the resource.
Then, when requests come in, it adds all the required caching headers to attempt "eternal" caching by intermediate caches and the client browser. It does this using the
cache-headers plugin.
Configuration
You may want to control which file types are hashed and cached, or exclude all hashing and caching in the development environment. For details see the configuration documentation for the
Resources plugin.
Last updated by admin 1 year ago
Last updated by admin 1 year ago