Caching Page/gsp fragments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Caching Page/gsp fragments

scryan
Is there a standard way to cache gsp templates?  I have a template that is expensive to build but does not change once it is built and like a menu it is included in each page.  It is unique for each user but once built should be reused.  Is there some thing built into Grails or another caching solution?

Thanks
Scott Ryan


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Caching Page/gsp fragments

tomas lin
Have you looked into Rob Fletcher's Spring Cache plugin (
http://www.grails.org/plugin/springcache )? Built exactly with this
use case in mind.

The idea is that you would define page fragments rendered by your
controllers and the plugin will catch page sections when you include
them via the g:include tag.

There is a good example of how something like this would work in the docs -

http://gpc.github.com/grails-springcache/docs/manual/guide/4.%20Content%20Caching.html#4.1.%20Caching%20and%20Flushing%20with%20Controller%20Actions

On Wed, Dec 1, 2010 at 11:57 PM, Scott Ryan <[hidden email]> wrote:

> Is there a standard way to cache gsp templates?  I have a template that is expensive to build but does not change once it is built and like a menu it is included in each page.  It is unique for each user but once built should be reused.  Is there some thing built into Grails or another caching solution?
>
> Thanks
> Scott Ryan
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Caching Page/gsp fragments

scryan
THanks for the direction.  I need to see if this is per application caching or per user session.  The page fragment is different for each user so it looks like this solution might not work since it looks to be application wide but I need to look into the plugin more so I understand if this is the case.  

Do you know if the caching of the page fragment is per user session or per application?  i imagine if not I could just key the cache entry to the users session.

Thanks again for the heads up.

Scott Ryan


On Dec 1, 2010, at 6:06 PM, Tomas Lin wrote:

> Have you looked into Rob Fletcher's Spring Cache plugin (
> http://www.grails.org/plugin/springcache )? Built exactly with this
> use case in mind.
>
> The idea is that you would define page fragments rendered by your
> controllers and the plugin will catch page sections when you include
> them via the g:include tag.
>
> There is a good example of how something like this would work in the docs -
>
> http://gpc.github.com/grails-springcache/docs/manual/guide/4.%20Content%20Caching.html#4.1.%20Caching%20and%20Flushing%20with%20Controller%20Actions
>
> On Wed, Dec 1, 2010 at 11:57 PM, Scott Ryan <[hidden email]> wrote:
>> Is there a standard way to cache gsp templates?  I have a template that is expensive to build but does not change once it is built and like a menu it is included in each page.  It is unique for each user but once built should be reused.  Is there some thing built into Grails or another caching solution?
>>
>> Thanks
>> Scott Ryan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Caching Page/gsp fragments

tomas lin
[ from the docs ]

By default page fragment cache entries are keyed on controller name,
action name and any request parameters (which can be from a query
string, POST body or those added by Grails URL mappings, e.g. the id
parameter on a standard show or edit action).

[ end quote ]

just make sure you pass in user id = no problem

On Thu, Dec 2, 2010 at 1:39 AM, Scott Ryan <[hidden email]> wrote:

> THanks for the direction.  I need to see if this is per application caching or per user session.  The page fragment is different for each user so it looks like this solution might not work since it looks to be application wide but I need to look into the plugin more so I understand if this is the case.
>
> Do you know if the caching of the page fragment is per user session or per application?  i imagine if not I could just key the cache entry to the users session.
>
> Thanks again for the heads up.
>
> Scott Ryan
>
>
> On Dec 1, 2010, at 6:06 PM, Tomas Lin wrote:
>
>> Have you looked into Rob Fletcher's Spring Cache plugin (
>> http://www.grails.org/plugin/springcache )? Built exactly with this
>> use case in mind.
>>
>> The idea is that you would define page fragments rendered by your
>> controllers and the plugin will catch page sections when you include
>> them via the g:include tag.
>>
>> There is a good example of how something like this would work in the docs -
>>
>> http://gpc.github.com/grails-springcache/docs/manual/guide/4.%20Content%20Caching.html#4.1.%20Caching%20and%20Flushing%20with%20Controller%20Actions
>>
>> On Wed, Dec 1, 2010 at 11:57 PM, Scott Ryan <[hidden email]> wrote:
>>> Is there a standard way to cache gsp templates?  I have a template that is expensive to build but does not change once it is built and like a menu it is included in each page.  It is unique for each user but once built should be reused.  Is there some thing built into Grails or another caching solution?
>>>
>>> Thanks
>>> Scott Ryan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Caching Page/gsp fragments

Jean Barmash 1
Scott,

One limitation of currently released springcache version is that it doesn't support ability to resolve within a cache, which can be used in several scenarios, including multi-tenancy and what you are asking for. 

Robert implemented a resolve mechanism that would allow it to be used with MT-like scenarios (basically implement ability to resolve the tenants).   See http://jira.codehaus.org/browse/GRAILSPLUGINS-2167

For your use case, you can probably configure a resolver based on user.   

Jean


On Wed, Dec 1, 2010 at 8:54 PM, Tomas Lin <[hidden email]> wrote:
[ from the docs ]

By default page fragment cache entries are keyed on controller name,
action name and any request parameters (which can be from a query
string, POST body or those added by Grails URL mappings, e.g. the id
parameter on a standard show or edit action).

[ end quote ]

just make sure you pass in user id = no problem

On Thu, Dec 2, 2010 at 1:39 AM, Scott Ryan <[hidden email]> wrote:
> THanks for the direction.  I need to see if this is per application caching or per user session.  The page fragment is different for each user so it looks like this solution might not work since it looks to be application wide but I need to look into the plugin more so I understand if this is the case.
>
> Do you know if the caching of the page fragment is per user session or per application?  i imagine if not I could just key the cache entry to the users session.
>
> Thanks again for the heads up.
>
> Scott Ryan
>
>
> On Dec 1, 2010, at 6:06 PM, Tomas Lin wrote:
>
>> Have you looked into Rob Fletcher's Spring Cache plugin (
>> http://www.grails.org/plugin/springcache )? Built exactly with this
>> use case in mind.
>>
>> The idea is that you would define page fragments rendered by your
>> controllers and the plugin will catch page sections when you include
>> them via the g:include tag.
>>
>> There is a good example of how something like this would work in the docs -
>>
>> http://gpc.github.com/grails-springcache/docs/manual/guide/4.%20Content%20Caching.html#4.1.%20Caching%20and%20Flushing%20with%20Controller%20Actions
>>
>> On Wed, Dec 1, 2010 at 11:57 PM, Scott Ryan <[hidden email]> wrote:
>>> Is there a standard way to cache gsp templates?  I have a template that is expensive to build but does not change once it is built and like a menu it is included in each page.  It is unique for each user but once built should be reused.  Is there some thing built into Grails or another caching solution?
>>>
>>> Thanks
>>> Scott Ryan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email