DEV Community

BmPdDNbK
BmPdDNbK

Posted on

A crude workaround for fixing stale static asset caching

A while back, I used Nginx reverse proxy caching for static files, and found that after deployment, clients were still pulling old files. Later, I used a pretty crude but effective workaround: add a custom query fingerprint to the asset path and change it on every build.
I added a line in the CI step to generate a fingerprint, and used this value directly:
BUILD_FINGERPRINT=nJ4KUcQ7r621TfaZ3QROayoHHDJdV8Jw
Then I used this variable to replace asset_version in the Nginx config (details omitted). On the frontend side, I also changed it to:

That completely broke the cache, and even CDN edge nodes would refresh properly.

Top comments (0)