Cache Filter

  • Tags: /
  • Latest: 0.5
  • Last Updated: 21 January 2010
  • Grails version: 1.1 > *
  • Authors: jga
0 vote
Dependency:
compile ":cachefilter:0.5"

 Documentation

Summary

Installation

grails install-plugin cachefilter

Description

This plugin permits to easily use oscache caching filter with grails (http://www.opensymphony.com/oscache/wiki/CacheFilter.html)

This servlet filter enables you to transparently cache generated html pages (and binary contents) of your grails application. Page caching allows to reduce server loads (by avoiding calls to controllers and gsp pages).

Usage :

declare your filters in conf/Config.groovy :

for example :

cachefilter {
    filters= [
        filterStatic : [
            enabled: true,
            scope:'application',
            time:3600,
            expires:'time',
            pattern: '/images/*,/css/*'
        ],
        filter1 : [
            enabled:true,
            scope:'application',
            time:120,
            pattern:'/book/list'
        ]

] }

Previous example defines 2 filters, named filterStatic and filter1. Each filter can have distinct parameters.

Parameters :

The parameter enabled permits to deactivate a filter. enabled is true by default.

with the pattern parameter, you define the URL patterns for the filter. This parameter is mandatory. Each Url pattern (url-pattern) is separated by ','.

Others parameters are those defined by CacheFilter (http://www.opensymphony.com/oscache/wiki/CacheFilter.html).

Some parameters used to tune content caching :

time : the default time (in seconds) to cache content for (default value is 3600 seconds).

scope : the default scope to cache content : application (default), session, request or page.

expires : defines if the Expires http header will be sent : on (default), off or time

lastModified : defines if the Last-Modified http header will be sent . possible values are on, off, initial (default)

cron : cron expression to define when cache will expire (ex : "* * * * Sunday" )