I'm trying to wrap my head around how static assets work in a production environment, the documentation seems rather scares, but it could just be me.
According to http://www.phoenixframework.org/docs/deployment i should run MIX_ENV=prod mix phoenix.digest
, as a part of my deployment. This seems to duplicate all my assets, with a string concatenated to the name, which is then served if using static_path/2
, i suppose this has something to do with caching bust on deploy. Great!
The digest function also creates manifest.json inside my priv folder, it looks something like this..
{"images/calltoaction.png":"images/calltoaction-13cfefeb09c991b12090bcf0a10f2dd2.png","fonts/fontawesome-webfont.woff2":"fonts/fontawesome-webfont-4b5a84aaf1c9485e060c503a0ff8cadb.woff2","im.....
I suppose Phoenix uses this to map the assets to their corresponding version.Please do correct me, if i'm completely wrong here. Oooh well, on to my question.
In my application the administrators are able to upload images in the administration panel, these are uploaded to /priv/static/images/model/version/..
. The problem is that these freshly uploaded images, are not in the manifest.json file, and therefor won't be shown?
This seems very funky, as new images are not shown, neither is replaced images etc. How would i handle this problem? Should i upload my images to another place, that shouldn't be digested?
The manifest is a caching feature. It is used by static_path
to generate links pointing to the assets. If you can't use it for all assets, because they are being uploaded dynamically, you don't need to use it. In other words, you should be able to upload your assets and just use static_path
as usual and they should be served like in development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With