[MGNLCACHE-192] Javascript resources not gzip compressed due to misconfiguration Created: 31/May/16  Updated: 17/Jan/18  Resolved: 19/Dec/17

Status: Closed
Project: Cache Modules
Component/s: None
Affects Version/s: None
Fix Version/s: 5.5.7, 5.6.1

Type: Bug Priority: Major
Reporter: Christopher Zimmermann Assignee: Maxime Michel
Resolution: Fixed Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File css-is-compressed.png     PNG File js-is-not-compressed.png    
Issue Links:
Relates
causality
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Release notes required:
Yes
Date of First Response:
Sprint: Basel 126, Basel 127
Story Points: 0.5

 Description   

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.



 Comments   
Comment by Christopher Zimmermann [ 31/May/16 ]

According to this stackoverflow post, the correct mimetype is application/javascript

http://stackoverflow.com/questions/9664282/difference-between-application-x-javascript-and-text-javascript-content-types
http://www.rfc-editor.org/rfc/rfc4329.txt
Also:
https://www.maxcdn.com/one/tutorial/mime-types/

Comment by Jonathan Ayala [ 25/May/17 ]

Hello,

Changing mimetype causes problems when accessing admin central and loading file /VAADIN/widgetsets/info.magnolia.widgetset.MagnoliaProWidgetSet/XXXXXXXXXX.cache.js

More information provided in the linked ticket.

Regards.

Generated at Sun Feb 11 23:53:06 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.