Phoenix digester/compression

118 views
Skip to first unread message

Alizain Feerasta

unread,
Mar 8, 2021, 9:21:39 AM3/8/21
to phoenix-core
Currently, Phoenix's Digester does both digesting and compression. This doesn't work very well within a webpack environment. We use webpack to construct bundles, support dynamic module, and append content hashes to files for production.

Crucially, webpack exports a `manifest.json` file for us to be able to use! I'd like to split up Phoenix's Digester into two separate pieces so that we can support this use-case.

In the non-webpack case, it would look something like this:
- Digester runs, digests files, and generates cache_static_manifest.json
- Separate Compressor runs, compressing digested files to gzip and/or brotli
- At runtime, Endpoint loads the cache_static_manifest.json to translate static assets (and Plug.Static handles serving compressed versions of those files)

In the webpack case, we could then do something like:
- WebpackDigester runs, reads webpack's manifest.json, and generates cache_static_manifest.json. It won't need to digest the files because webpack's already done the digesting.
- Separate Compressor runs, compressing digested files to gzip and/or brotli
- At runtime, Endpoint loads the cache_static_manifest.json to translate static assets (and Plug.Static handles serving compressed versions of those files)

By separating the Digester and Compressor steps, we can make the Digester step a behaviour, and users can swap implementations in their config files based on whatever environment they're in.

What do y'all think?

Chris McCord

unread,
Mar 8, 2021, 9:29:54 AM3/8/21
to phoeni...@googlegroups.com
I'd recommend trying to see if you can support this via  third-party library. Our digester is baked at this point and I don't have any near term plans to make deviations. Thanks!

--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/08600070-c5f2-4aba-80e5-bc7333443af1n%40googlegroups.com.

Alizain Feerasta

unread,
Mar 8, 2021, 9:40:48 AM3/8/21
to phoenix-core
Gotcha, thanks.

I'm curious, is this motivation to minimize code-churn/bugs, or to direct maintainer's energy elsewhere, or to keep the user-facing API the same, or something else?

Chris McCord

unread,
Mar 8, 2021, 9:41:28 AM3/8/21
to phoeni...@googlegroups.com

Alizain Feerasta

unread,
Mar 8, 2021, 9:45:33 AM3/8/21
to phoenix-core
:thumbsup:

Thanks again!

Reply all
Reply to author
Forward
0 new messages