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.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..
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
joaoevangelista
This file contains a mapping of the resource url with the real file name:
/assets/js/jquery.jsthat your templates use and the target is the digested file, Phoenix will lookup the requesting path/assets/js/jquery.jsin 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 tocache_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.digestfoobar
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_manifestfile at all? Aside from the static links being generated without the digest, is there any other side effect from this?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
I’m pretty certain I can still get the gzipped version of the assets by setting
gzip: trueonPlug.Static, I’ve tested this and I am getting the gzipped version with the above settings even without runningphx.digestor including any manifest file.Can you clarify what do you mean by “cache” here? how is the manifest used for caching?
joaoevangelista
The browser cache.
Oh yes, if you do that Plug will look for a gz version of the requested file, that works too