Struts 2
  1. Struts 2
  2. WW-3765

Improve performance of FreeMarker Template caching

    Details

    • Flags:
      Patch

      Description

      Struts2 having option to enable the freemarker template caching with reloading the template with time delay which helps us to improve the performance.

      In our application we are using the strut2 in-built UI freemarker template. We need the caching option without reloading the templates after the specific time delay.

      Caching option is more powerful if we have an option for enabling\disabling the reload

      Proposed Solution

      Struts.xml
      <constant name="struts.freemarker.templatesCache.required" value="true"/>

      FreeMarkerManager.java

      protected boolean templateUpdateRequired;
      @Inject(STRUTS_FREEMARKER_TEMPLATES_RELOAD_REQUIRED)
      public void setTemplateUpdateRequired(String templateUpdateRequired)

      { this.templateUpdateRequired ="true".equals(templateUpdateRequired); }

      Update createConfiguration(ServletContext servletContext) Method
      configuration.setSetting(Configuration. TEMPLATE_RELOAD_ REQUIRED _KEY, templateUpdateRequired);

      Configuration.java

      String TEMPLATE_RELOAD_ REQUIRED _KEY= "template_reload_required";

      TemplateCache.Java

      protected boolean templateUpdateRequired;

      Update getTemplate(TemplateLoader loader, String name, Locale locale, String encoding, boolean parse) Method
      ...
      if (templateUpdateRequired !=false && now - cachedTemplate.lastChecked < delay) {

        Issue Links

          Activity

          Lukasz Lenart made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.3 [ 12320642 ]
          Fix Version/s 2.3.2 [ 12319199 ]
          Lukasz Lenart made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Lukasz Lenart [ lukaszlenart ]
          Resolution Not A Problem [ 8 ]
          Vijayakannan made changes -
          Comment [ Hope setting the updateDelay=-1 in struts.xml will help us to avoid the template reloading

          I have tested the same in sample application. it's working
          <constant name="struts.freemarker.templatesCache.updateDelay" value="-1" />

          Thanks a lot for all your comments
          ]
          Vijayakannan made changes -
          Field Original Value New Value
          Link This issue is related to WW-3467 [ WW-3467 ]
          Vijayakannan created issue -

            People

            • Assignee:
              Lukasz Lenart
              Reporter:
              Vijayakannan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development