Hi,
how can I enable compression (gzip or deflate) for the output that Neos generates? I want the HTML to be sent gzipped to the client.
Hi,
how can I enable compression (gzip or deflate) for the output that Neos generates? I want the HTML to be sent gzipped to the client.
This is the job of the http-server serving your cms. In case you’re using apache 2.4 you can have a look at http://httpd.apache.org/docs/current/mod/mod_deflate.html
The configuration will depend on which http-server you’re using.
For example: nginx doesn’t support a .htaccess file but also supports output compression via gzip.
http://nginx.org/en/docs/http/ngx_http_gzip_module.html#example
Well, I already have the according configuration in my .htaccess:
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
But It looks like this only works for actual files (.html, .css) and not for responses of serverside scripts, such as the Neos CMS.
do you have a link to your project?
Not yet, the website is still in development. I could send you the link via email?
You can put the following code to the end of your httpd.conf
# Deflate Compression by MimeType
<IfModule deflate_module>
<FilesMatch "\.(js|jpg|jpeg|gif|png|css|woff|svg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Common Fonts
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/font-woff
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font-otf
</IfModule>
And don´t forget to activate the required modules:
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
LoadModule filter_module modules/mod_filter.so
This will dramatically increase your websites performance!
Unfortunately this only works for resources (static html files, css and js files etc) but not for the Neos output.
I would like to write a post-processor module/package for neos, any hints where to start?
Are you looking for something like this https://github.com/Flownative/neos-compressor ?
No, this only minifies the HTML.
I’ve come across the same issue, but didn’t find any easy solution. However it should be possible to write something that hooks in and Gzips the output. Would be a nice addition to the neos-compressor
package.
Pretty sure it works for dynamic content too, if I’m not missing the point here:
Check this site and compare:
http://checkgzipcompression.com/?url=http%3A%2F%2Fwww.neos.io
I figured it out (thanks to @christianm for his great hints) and created a Package: https://github.com/c0necto/neos-compressor
This package enables gzip/deflate compression for the Neos output. Additionally, the head and body section HTML of the TYPO3.Neos:Page prototype is being minified using the compressor of wyrihaximus/html-compress (borrowed from flownative/neos-compressor)
Nice, but why not a PR for the Flownative package, sounds like code duplication to me. Let’s collaborate and avoid duplicate don’t be shy
And the current implementation compress the content on every request … as our TypoScript Content Cache will not handle gziped content it will be hard to solve, but should lower the load on the server. You can also avoid doing compression for small page, but that micro optimization (and maybe just theorical)