I have a sitemap file that is located in priv/static/sitemaps/sitemap1.xml
▾ priv/
▸ gettext/
▸ repo/
▾ static/
▸ assets/
▸ images/
▾ sitemaps/
sitemap.xml
sitemap1.xml // <=================
favicon.ico
robots.txt
In addition, I have added the sitemaps folder to static_paths in lib/MyApp.ex
def static_paths, do: ~w(assets fonts images favicon.ico robots.txt sitemaps)
However, it continues to serve an outdated version of my sitemap when I visit https://www.myapp.com/sitemaps/sitemap1.xml even after multiple deploys / restarts. I even sshed into the server and opened up the file to confirm that the file was different from the one being served.
Am I missing a step? Or is there another way of serving static files?
You can generate the file to a known location, and put a new
Plug.Staticcall in yourEndpoint:If your worker is only specifying the relative
privdirectory, it is probably saving to a different directory than the one the release uses. Releases use the application's directory inside the release, rather than the working directory. You can ensure you save to the application's directory by usingApplication.app_dir/1:However, this is not a good idea because you're generating dynamic content at runtime, and injecting it into what is supposed to be a pre-compiled release, so I think the extra
plug Plug.Staticsuggestion above is better. Or generate the content at compile-time, and include it in the release.