How to handle web application static resources wich browser-cache in kubernetes?

We are trying to migrate or frontend apps to kubernetes. But when doing a rolling update there is a possibility that the users get 404 due to cacheing with unique sha1 hashes in the URI.

Example:

  • Override FROM image's ENV in Dockerfile
  • Image upload and display within a docker environment
  • Docker image with specific node version
  • Reading in environment variables from an environment file
  • Docker push re-sends layers to private repository
  • Add docker publish step to sbt-release process with new tag
  • Simplified directory structure after build #1

    /index.html
    /static/147964a6b54c/app.js
    /static/147964a6b54c/style.css
    

    Simplified directory structure after build #2

    /index.html
    /static/978b4ccd1dbb/app.js
    /static/978b4ccd1dbb/style.css
    

    The app uses Cache-Control: public

    We have 10 pods running in kubernetes.

    We begin rolling update with default update interval of 60 sec.

    The problem that can happend now is that the new index.html requests the new URI to app.js (with new hash) but it gets redirected to a container running the old app which does not have that path and therefore throws a 404.

    One solution is to only rely on etag header but that makes the clients doing a roundtrip each time and that should not be needed. index.html should use this solution but not the other assets.

    I wonder if any other people have run into this situation and found a good solution?

  • Background OpenCpu R process in Docker
  • How to use docker with mongo to achieve replication and with opening authentication
  • Proper handling of request_uri in double nginx reverse proxy?
  • Mounting a container volume into another container on a different path
  • Docker VS Native installation on a server. How to recover from downtime mysql/mariadb without data lloss
  • Docker duplicates UDP packets
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.