Mukund Sonaiya
Mukund Sonaiya

Reputation: 461

How to do static file versioning like images available in asset folder in Angular4

On updating a new version of my Angular4 site. The images are not re-downloaded on new version update. Browser continues using cached assets until we manually clear the cache. I am using ng-cli for deployment.

Upvotes: 1

Views: 1145

Answers (1)

Avid Coder
Avid Coder

Reputation: 18387

You can use a version param in your image URL as follow

https://example.com/assets/images/foo.png?v=1.0.

Then you can up the version number whenever the image is updated to force the browser to refetch. (cache busting).

<!-- In your html -->
https://example.com/assets/images/foo.png?v={{assetVersion}}.

Upvotes: 1

Related Questions