ludofischer / metalsmith-gzip

Metalsmith plugin for gzipping the output files.
MIT License
18 stars 3 forks source link

what httpd configuration to use gzipped resources? #10

Closed oupala closed 6 years ago

oupala commented 6 years ago

Can you provide an example of an httpd configuration to use gzipped resources?

I can enable mod_deflate on httpd to enable on-the-fly gzipping. But when we use metalsmith-gzip, gzipped resources are already existing and hence we don't need on-the-fly gzipping.

We need apache to use the already existing gzipped resources. How can we tell apache to do so?

ludofischer commented 6 years ago

It’s a long time I don’t configure Apache. The simplest solution would be to only upload the gzipped resources to the server. You don’t need a .gz extension. Else you would need to map requests to the gzipped files with a rewrite rule: https://httpd.apache.org/docs/current/mod/mod_rewrite.html

oupala commented 6 years ago

I found a way better solution that rewriting urls: it is content negociation (see this post for more informations).

The problem is that solution require to have gzipped resources, and .gz named resources.

Do you think it would be possible to add a new option to this plugin, in addition to the overwrite: true option?

This option could for example be replace: true.

  1. with .use(compress();
    • before
    • style.css
    • after
    • style.css // original file
    • style.css.gz // gzipped file
  2. with .use(compress({overwrite: true});
    • before
    • style.css
    • after
    • style.css // gzipped file (without extension in its name)
  3. with .use(compress({replace: true});
    • before
    • style.css
    • after
    • style.css.gz // gzipped file (with extension in its name)

Let me know.

oupala commented 6 years ago

see #11