Poisoned cache breaks PWA update when CDN is enabled
jclaveau
PROOP

3 hours ago

  • I tested the CDN feature on my PWA app (very nice feature btw)

  • This made me realize some issues in my Caddyfile, the main one being missing assets responding 200 with the content of my index (as expected to show the 404 within the rendered app). Worse: these responses where cachable for 1 year

  • I fixed all the caddy rules (true 404 for missing assets + no-cache)

  • i added hashes to ensure the assets are reloaded

  • I configured my service worker to be more aggressive regarding cache (skipWaiting / clientsClaim / cleanupOutdatedCaches)

  • There is one error I can't remove: bad-precaching-response: bad-precaching-response :: [{"url":"https://www.hiphiphip.app/assets/vue-query-legacy-Bewys-1w.js","status":404}]

  • I spent a while adding a script to catch these poisoned pre-cached assets and remove them. I implemented tests ensuring they are removed and smoke tests to ensure the script works in production

  • When the CDN is disabled, everything works like a charm

But,

If I enable the CDN again, it comes back instantly. And the users encountering this will never have an updated app.

So I guess my sw.js has been cached before I fixed my Caddyfile and Faslty has an older version of it.

So my question: Can I flush the CDN cache for my domain? I disabled / reenabled it a lot without succes.

Project-Id: 65aff0db-6586-4be0-8420-b2e67ae4378d

2 Replies

3 hours ago

Hey, at the moment you can purge individual assets using the HTTP PURGE method, e.g.

curl -x PURGE

We are working on implementing asset purging for the entire domain, but it is not yet available on the dashboard. I am able to do it manually if you'd like.


3 hours ago

Also, isn't our cache TTL 2 hours, I wouldn't say that's "never".


Welcome!

Sign in to your Railway account to join the conversation.

Loading...