Uploaded image for project: 'Cache Modules'
  1. Cache Modules
  2. MGNLCACHE-192

Javascript resources not gzip compressed due to misconfiguration

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 5.5.7, 5.6.1
    • None
    • None
    • None
    • Yes
    • Basel 126, Basel 127
    • 0.5

      By default magnolia is configured to (gzip) compress html, js, and css resources. This is configured at: /modules/cache/config/compression/voters/contentType/allowed

      CSS and HTML are correctly compressed, but JS files are not because their actual mimetype is "application/javascript" - while the compression config specifies "application/x-javascript".

      Possible solution: change js entry to "application/javascript" entry, or add an additional one.

      Ensure that the same mimetype is used for JS everywhere.
      Also check the rest of the configuration for potential js mime-type misconfiguration - for example:
      /modules/cache/config/contentCaching/defaultPageCache/browserCachePolicy/policies/resources/voters/contentType/allowed
      (ie search for "application/javascript" and "application/x-javascript" in config app.)

      To reproduce:
      Run magnolia locally. (Our public demo seems to compress JS in another way.)
      Open a page in chrome - like http://localhost:8080/magnoliaAuthor/travel/about.html
      Open the devtools and switch to "network" tab.
      Click on a css file, (like: bootstrap.min....css) And notice Response Headers has Content-Encoding: gzip.

      Click on a js file (like respimage.min...js) And notice that Response Headers has no Content-Encoding (Note that this file is 8634 bytes when not compressed, and around 4000 when compressed.

      Big thanks to marvink2 for reporting.

        Acceptance criteria

          1. css-is-compressed.png
            480 kB
            Christopher Zimmermann
          2. js-is-not-compressed.png
            483 kB
            Christopher Zimmermann

              mmichel Maxime Michel
              czimmermann Christopher Zimmermann
              Votes:
              6 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD