Multiple suffixes for media types

Hi,

I have few relatively large datasets as gzipped JSON files, with extension .json.gz. The hugo development server serves these files with the application/x-gzip MIME type. But, I would like them to be served as application/json files, because then the browser will automatically decompress them and consider them as normal JSON files. This plays more nicely with jQuery AJAX calls etc.

I’ve found this page: https://gohugo.io/templates/output-formats/

I could set the suffix of “application/json” to .json.gz, but it it seems like it will override the setting for normal .json files. Is it possible to configure multiple suffixes for a mime type?

Thanks in advance,
Lucas

No, but you can define multiple mime types, which I guess is what you want.

I don’t believe so: I would like both .json and .json.gz files to be served with the mimetype application/json. How would I approach that?

Thanks,
Lucas

I’m not sure if this is possible to define in Hugo (it should be …), but the JSON MIME type is basically

application/json+json

Where the last part is the suffix.

So application/json+js would still be the same MIME type application/json, but with a different suffix. But as I said, thinking about it I think there is a limitation in Hugo on this.

Alright thanks for your response, and something that sounded like a possible workaround. Unfortunately I cannot use the character “+” in Hugo mediatypes.

A feature that would be really awesome is if you could modify the HTTP headers that get sent for certain paths (using wildcards).

Could you create an issue on GitHub and point back to this thread? It should be possible, but it needs some work.

HTTP headers can not be set from a static site.

Yep I will.

Regarding the last point, I meant adding a configuration section to config.toml that allows you to specify what kind of headers are sent by the builtin hugo server for certain paths.