How to enable output compression?


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

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.

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
  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/
  AddOutputFilterByType DEFLATE application/x-font-otf 

And don´t forget to activate the required modules:

LoadModule deflate_module modules/
LoadModule expires_module modules/
LoadModule filter_module modules/

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 ?

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:

I figured it out (thanks to @christianm for his great hints) and created a Package:
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 :slight_smile:

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)

1 Like