Grails
  1. Grails
  2. GRAILS-5560

GroovyPagesTemplateEngine does not cache compiled templates for several variants of createTemplate

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2-RC1, 1.2-RC2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      There are a lot of createTemplate variants on the engine, but very few of them actually attempt to get a page from the cache.

      In particular createTemplate(String content, String pageName) never attempts to cache.

      Surely we can generate a page name for caching purposes that is based on an SHA1 digest of the source template? This may take a little while to compute, but likely a lot less time than compiling the template and leaking permgen? Even then, the digest is only needed if there is no way to tell the engine what the lastmod time is of the template. If there is an extra variant:

      createTemplate(String content, String pageName, Date lastModified)

      ...then this problem can be circumvented also.

        Issue Links

          Activity

          Hide
          Luke Daley added a comment -

          Lari, I'm assigning this to you are the expert here.

          I apologise if this is too forward.

          Show
          Luke Daley added a comment - Lari, I'm assigning this to you are the expert here. I apologise if this is too forward.
          Hide
          Lari Hotari added a comment -

          It would be quite easy to do this change, but I think we should do some kind of re-designing before adding new features. I linked GRAILS-3818 and GRAILS-6809 to this issue.

          I've identified 3 types of use cases that should be supported:

          • usage as Grails view layer "rendering engine" (designed for this)
          • Dynamic template engine (like Freemarker/Velocity)
          • usage as template engine outside the web-request processing

          There are different concerns:

          • template parsing/compilation
          • template rendering/execution
          • template caching
          • template/view resolution

          I don't think they should be all supported/implemented on the same interface or service bean.

          Any ideas?

          Show
          Lari Hotari added a comment - It would be quite easy to do this change, but I think we should do some kind of re-designing before adding new features. I linked GRAILS-3818 and GRAILS-6809 to this issue. I've identified 3 types of use cases that should be supported: usage as Grails view layer "rendering engine" (designed for this) Dynamic template engine (like Freemarker/Velocity) usage as template engine outside the web-request processing There are different concerns: template parsing/compilation template rendering/execution template caching template/view resolution I don't think they should be all supported/implemented on the same interface or service bean. Any ideas?
          Hide
          Lari Hotari added a comment -
          Show
          Lari Hotari added a comment - I started a new thread on the Grails-dev mailing list about this: http://grails.1312388.n4.nabble.com/GroovyPagesTemplateEngine-GSP-related-re-design-needed-tp3215501p3215501.html .
          Hide
          Graeme Rocher added a comment -

          I have implemented the PageRenderer class which allows view/template rendering outside of a request. It doesn't currently cache (although GroovyPagesTemplateEngine does)

          Not sure what more should be done on this issue

          Show
          Graeme Rocher added a comment - I have implemented the PageRenderer class which allows view/template rendering outside of a request. It doesn't currently cache (although GroovyPagesTemplateEngine does) Not sure what more should be done on this issue
          Hide
          Malte Huebner added a comment -

          We are developing a huge grails app where gsp-templates are stored in the database. These templates are used to render in the frontend.
          As they are not really cached by GroovyPagesTemplateEngine (createTemplate(res, true)) our app has a big memory leak and hangs every 42 hous. We would really appreciate if this improvement will be part of the next release. If not we must switch to another template system.

          Show
          Malte Huebner added a comment - We are developing a huge grails app where gsp-templates are stored in the database. These templates are used to render in the frontend. As they are not really cached by GroovyPagesTemplateEngine (createTemplate(res, true)) our app has a big memory leak and hangs every 42 hous. We would really appreciate if this improvement will be part of the next release. If not we must switch to another template system.
          Hide
          Graeme Rocher added a comment -

          @Malte - how are they rendered? What APIs are you using to render them? If you are using variants of the methods that don't cache then you would have a leak, but you should not be

          Show
          Graeme Rocher added a comment - @Malte - how are they rendered? What APIs are you using to render them? If you are using variants of the methods that don't cache then you would have a leak, but you should not be

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              Marc Palmer
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Last Reviewed:

                Development