Skip to content

fix: users stay on the old version after a deployment (browser cache) #296

Description

@MateoLostanlen

Problem

After a deployment, users keep seeing the old version of the platform. They have to manually clear their browser cache (or hard refresh) to get the new version.

Cause

Nginx does not send any Cache-Control header. Browsers then apply heuristic caching to index.html, which references the JS bundles by their old hashed names. As long as this stale index.html stays in cache, the user loads the old application.

The runtime config file config/app-config.js (not content hashed) has the same problem.

Proposed solution

In nginx/default.conf:

  • Cache-Control: no-cache on location /: index.html and app-config.js are revalidated on every load (304 response if unchanged, so nearly free)
  • Cache-Control: public, max-age=31536000, immutable on location /assets/: Vite bundles are content hashed, they can be cached indefinitely

Note

The fix takes effect on the next deployment. Users who already have a stale index.html in cache will need to refresh one last time, after that updates will be automatic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions