Grails - Full Page Caching

343 Views Asked by At

I'm putting up a small website where only one page needs information from a database, and the rest of the pages are static. How can I implement full page caching for those static pages while still using the default fragmented cache system for the one page that needs it? I would prefer to use the same sitemesh layout for all the pages if I can. The sitemesh layout only contains static content.

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the <cache:block> tag of the cache plugin (installed in Grails 2.X apps by default) to cache all or part of the static pages. Here's how you would use it to cache the entire page

<cache:block>

<html>
  <head>
  </head>
  <body>my static page</body>
</html>

</cache:block>

Even without using this plugin, I'm pretty sure there is already a caching mechanism for GSP rendering (in the production environment) so I doubt you'll see a big performance gain.

If these static pages require execution a controller action (rather than just rendering a view), you can cache that too using the @Cacheable annotation provided by the cache plugin