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.digestwould 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 likeapp.build_digest_ad21d.phx_digest_sd212.js. - I was able to disable this behavior by removing the
cache_static_manifestfrom 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
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
The browser cache.
Oh yes, if you do that Plug will look for a gz version of the requested file, that works too
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









