foobar

foobar

a bit of background,

  • I’m working on a project that has its own js build pipeline, and the build output already includes a digest hash in their names. Running mix phx.digest would append another layer of digest to the file names. I wanted to include script tags without this second digest.
  • When the app is running under prod env/build, generating static paths with Routes.static_path(conn, "app.build_digest_ad21d.js") produces outputs like app.build_digest_ad21d.phx_digest_sd212.js.
  • I was able to disable this behavior by removing the cache_static_manifest from the endpoint config, and get the static paths I want without the extra digest.

so, my questions here are, what does cache_static_manifest do exactly and how does it affect the static server? The name seems to suggest it has something to do with caching? Does it control how the static server cache the files in memory or something?

Running mix phx.digest seems to also generate the gzipped version of the static files. Would disabling this manifest means the static server have to compress all the static files on the fly everytime?

If anyone can point me to someplace that documents this behavior, that would be very helpful as well. I could only find the mention on Phoenix.Endpoint that says it points to the json manifest file, but there is no mention on how this json manifest file itself gets used or how it affects the Plug.Static..

Showing Posts 1 to 5

joaoevangelista

joaoevangelista

This file contains a mapping of the resource url with the real file name: /assets/js/jquery.js that your templates use and the target is the digested file, Phoenix will lookup the requesting path /assets/js/jquery.js in this json and respond with the digested file. If Phoenix is not serving static assets you can remove it. If Phoenix is serving assets and your js pipeline builds one json file that maps the normal file name to the digested in the file system you can pass it to cache_static_manifest, e.g.: cache_static_manifest: "/priv/custom-manifest.json"

Since you already have a js pipeline with digestion you don’t need to run mix phx.digest

foobar

foobar OP

I’m not generating my own manifest file, at least not the one that is used by by Phoenix, though I might consider that if I really need to. Is the format/spec documented anywhere?

More to the point, I suppose my question really is more like; can I do without the cache_static_manifest file at all? Aside from the static links being generated without the digest, is there any other side effect from this?

joaoevangelista

joaoevangelista

Are you including hardcoded your using Routes.static_path/2 ? if is the latter you can append another digest and let phoenix handle the digest. Or you could remove the digest from the js build pipeline and let only Phoenix’s.

The browser would not benefit from caching or downloading the gzip version of the static resource.

Not that I could find.

Yes, it would not be optimal because of the cache, but you can.

foobar

foobar OP

I’m pretty certain I can still get the gzipped version of the assets by setting gzip: true on Plug.Static, I’ve tested this and I am getting the gzipped version with the above settings even without running phx.digest or including any manifest file.

Yes, it would not be optimal because of the cache, but you can.

Can you clarify what do you mean by “cache” here? how is the manifest used for caching?

joaoevangelista

joaoevangelista

The browser cache.

Oh yes, if you do that Plug will look for a gz version of the requested file, that works too

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews