Kentico 8.1 Gzip Compression

Jeff Anderson asked on November 10, 2014 17:13

We recently upgraded from Kentico 5.5 where we enabled compression in IIS and added the AppSettings key CMSAllowGzip. This option appears to have been removed in version 8. According to Google PageSpeed, our CSS and JavaScript are not being compressed by Kentico. I have performed the following

Settings > System > Performance Enable output compression - checked Allow resource compression - checked Allow JavaScript minification - checked Allow CSS minification - checked

I have all of my JavaScript and CSS minified and served via the GetResource.ashx file handler

All of the CSS and JavaScript files are pre-minified. Meaning, they were minified prior to loading them into Kentico. StyleSheets and JavaScript files were loaded into Kentico via the Admin interface in "CSS Stylesheets" and "JavaScript files"

We do pay for premium support, however, I am unable to wait 24 hours between each response

Kentico EMS 8.1 no hotfix installed as a web application IIS 7.5

Thanks

Recent Answers


Martin Danko answered on November 24, 2014 15:17 (last edited on November 24, 2014 15:17)

Hi Jeff,

If the final link to the CSS is in the format: /CMSPages/GetResource.ashx?stylesheetname=CorporateSite then the CSS minification is working as the link would be outputted as /CMSPages/GetCSS.aspx?stylesheetname=CorporateSite if minification was either disabled or not working correctly.

Some information about how minification works could be found in the Documentation: Using code minification and compression

Minified are only CSS and JS files uploaded by CMS Site Manager, and of course if you will open the JS or CSS file you don't see the minified version because if you will open the file in browser, it's loaded from the original file, the minification is handled on the Kentico (server) side on the page request, it's just the way how the file is delivered to the browser, it doesn't affect the original file so I hope this explains the difference.

For example: the response header with CSS minification turned on for the CorporateSite stylesheet is:

HTTP/1.1 200 OK
Cache-Control: public, must-revalidate
Content-Type: text/css
Content-Encoding: gzip
Expires: Wed, 24 Jul 2013 17:48:29 GMT
Last-Modified: Tue, 11 Sep 2012 10:01:13 GMT
ETag: cssstylesheet|1f2effc8-8c9c-41d5-9105-2e474ab1a0e8
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Content-Disposition: attachment; filename=CorporateSite.css
X-AspNet-Version: 4.0.30319
X-Frame-Options: SAMEORIGIN
X-Powered-By: ASP.NET
Date: Wed, 24 Jul 2013 17:48:29 GMT
Content-Length: 21600

while the minification turned off returns:

HTTP/1.1 200 OK
Cache-Control: public, must-revalidate
Content-Type: text/css
Content-Encoding: gzip
Expires: Wed, 24 Jul 2013 17:49:40 GMT
Last-Modified: Tue, 11 Sep 2012 10:01:13 GMT
ETag: cssstylesheet|1f2effc8-8c9c-41d5-9105-2e474ab1a0e8
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Content-Disposition: attachment; filename=CorporateSite.css
X-AspNet-Version: 4.0.30319
X-Frame-Options: SAMEORIGIN
X-Powered-By: ASP.NET
Date: Wed, 24 Jul 2013 17:49:40 GMT
Content-Length: 25860

so as you can see, the difference is the returned file size 21.6KB versus 25.86KB.

I suppose that the Google Page Speed is checking the size of physical file and not the one that is delivered directly into the browser via Kentico handler.

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.