Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-48386

SASS cache is not working as expected in runtime mode for plugins

    Details

      Description

      Tomcat or other application servers usually explode the resources in the web application in a temp folder, this means that the modified dates are not the original and if the server takes some milliseconds between copy .sass-cache resources and original resources the comparation fails and the css files are re-parsed.

      Analyzing this feature, I noticed that .sass-cache never is being persisted when is regenerated in order to avoid new regenerations, instead of this, the filters or servlets that use this feature (currently ComboServlet, AggregateFilter, StripFilter and DynamicCSSFilter) are generating another cache level, stored in a different way depending on the filter or servlet

      1. ComboServlet cache - Cache in Memory as PortalCache<String, byte[][]>
      2. AggregateFilter cache - Cache in File System with two files per data *_E_CONTENT_TYPE and *_E_DATA inside a aggregate temp folder.
      3. DynamicCSSFilter cache - Cache in FS also with two files, inside a css temp folder.
      4. StripFilter cache - Cache in Memory as ConcurrentLFUCache<String, String>

      These filters and servlets don't ensure new parsed for the same resource because, 1 and 4 are cache in memory that is invalidate in a Server reboot or if the cache is expired (PortalCache by default is expired after 10 minutes without use)

      And 2 and 3 are using the query string as part of the filename, so, if a parameter changes, eg. the browserId, the parser is executed again.

      Expected

      1. Resources should not be re-parsed if the plugin includes the sass-cache folder.
      2. If a resource is re-parsed, this resource will never be parsed again ensuring only one ruby task per resource.

      STEPS TO REPRODUCE
      1.- Deploy the portlet attached
      2.- Instance the portlet in a page
      3.- Delete the work folder for the portlet. It should eb something like /path/to/liferay-master/tomcat-7.0.42/work/Catalina/localhost/SassTest-portlet/css/http_/SassTest-portlet/css
      4.- Enable the following log traces in Control Panel. com.liferay.portal.servlet.filters.dynamiccss.DynamicCSSUtil to DEBUG
      5.- Go to the temp folder in Tomcat of the deployed portlet. It should be something like /path/to/liferay-master/tomcat-7.0.42/temp/2-SassTest-portlet/css
      6.- Change the date of the main.css file (touch main.css)
      7.- Change the language of the portal in the URL. Something like http://localhost:8080/es_ES or http://localhost:8080/hu_HU or http://localhost:8080/nl_NL

      ACTUAL RESULT
      The SASS is parsed with every request and this log trace appears
      16:43:28,134 DEBUG [http-bio-8080-exec-22][DynamicCSSUtil:218] Parsing SASS for /css/main.css takes 33 ms

      EXPECTED RESULT
      The SASS should not be parsed again and it should be read from the .sass-cache folder and this log trace should appear:
      16:39:35,137 DEBUG [http-bio-8080-exec-55][DynamicCSSUtil:169] Loading SASS cache from /localhost/SassTest-portlet/css/.sass-cache/main.css takes 1 ms

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              support-lep@liferay.com SE Support
              Reporter:
              jose.jimenez Jose Jimenez
              Participants of an Issue:
              Recent user:
              Jose Jimenez
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 2 weeks, 2 days ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.2 CE GA3
                  6.2.X EE
                  7.0.0 M2