Phoenix cache_static_manifest version is always 1

I noticed the version in my cache_manifest.json file wasn’t updating and I tried to fix it by following this guide, which mentions a :version option for the Endpoint module. But that didn’t seem to fix the issue and I notice it’s not mentioned in the current Phoenix docs.

"phoenix": {:hex, :phoenix, "1.4.2", "3a1250f22010daeee265923bae02f10b5434b569b999c1b18100b5da05834d93", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
"distillery": {:hex, :distillery, "2.0.12", "6e78fe042df82610ac3fa50bd7d2d8190ad287d120d3cd1682d83a44e8b34dfb", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},

Is there a prescribed way to handle cache invalidation that I’m missing?

I’m looking through the code for the digester and unless I’m missing something it seems like the version is hard-coded to 1:

It seems like there should be a version option like the guide I link above describes, which the Digester would respect, but it doesn’t look like it. If anybody more familiar with Phoenix source could confirm that, I can open an issue on GH.

I came back to this today and realized I was probably misunderstanding the purpose of the version key in the cache_manifest.json file. I couldn’t find any confirmation in the docs, but I’m guessing that key is meant to be used for schema versioning, not cache invalidation. I was misled by the example code in this blog post:

In any case, I had two main problems in my service worker I had to fix:

  1. Change fetch hook to refresh cache (since I couldn’t figure out how to invalidate it properly). I used the “Stale while revalidate” strategy here:
  2. Change start page (which I’m also caching) to use non-digested path to assets, since the digested path was getting out of date and breaking.

It’s likely there is probably a better strategy to dealing with service working caching with phoenix, so if anyone knows of one please share.