I can enable nginx gzip compression for MIME types. I however need to serve large files which have a different extension (.roadData). A .roadData is essentially json.
How can I ask nginx to serve .roadData files with compression?
Thanks
I can enable nginx gzip compression for MIME types. I however need to serve large files which have a different extension (.roadData). A .roadData is essentially json.
How can I ask nginx to serve .roadData files with compression?
Thanks
2
Answers
add mime type for your extension
enable compression for your mime type
to offload nginx from dynamic compression create .gz (filename.roadData.gz) files next to original files so nginx will response with pre-compressed files.
You can specify the MIME type for your custom extensions, like the following:
Then all the
.roadData
files will be served with the appropriate MIME type, and NGINX will compress them if you have specified that type for compression.In this way, you extend the server-wide MIME-types with your own, for another extension.
Alternatively, you can specify it as default for location, provided that
roadData
are stored in a single directory withou other files:Like the other answer mentions, pre-compressed gzip files make sense there, because you don’t want NGINX to recompress those large files on every request.
Use
gzip_static on;
and create a compressed version of the files.One of the most efficient tools there would be
zopfli
.