foobar

foobar

How do I turn off static assets digest and what does cache_static_manifest do exactly?

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..

First Post!

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

Last Post!

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

Where Next?

Popular in Questions Top

New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement