Closed.
Compression is a good idea, but this needs some thinking about. Off the top of my head:
Accept-Encoding needs to be parsed to determine if the client supports compression (and if so, which one)If you need a short-term solution, use nginx as a reverse proxy and let it do the compression with configuration like this:
gzip on;
gzip_proxied any;
gzip_types text/css text/plain text/xml application/xml application/javascript application/x-javascript text/javascript application/json text/x-json;
gzip_vary on;
gzip_disable "msie6";
compress text-based files to compile code
What do you mean by that? There's no such thing as compiled code for HTML, JavaScript, CSS, SVG etc.
However, integration with, for example, a LESS/SASS compiler or a JavaScript minifier could be considered.
@proyb6 There's no compilation happening in your example. If welcome.html contains the UTF8 string <h1>Hello, world!</h1>, the content returned is identical.
Compression would happen afterwards in both cases.
Already have GZIP in middleware
https://github.com/vapor/gzip-provider/blob/master/Sources/gzip-vapor/GzipMiddleware.swift
Most helpful comment
Compression is a good idea, but this needs some thinking about. Off the top of my head:
Accept-Encodingneeds to be parsed to determine if the client supports compression (and if so, which one)If you need a short-term solution, use nginx as a reverse proxy and let it do the compression with configuration like this: