jonny
jonny

Reputation: 131

How to force reload and clear cache on recent update in react

I have a React app that is deployed in amazon aws. Whenever i update the code, i need to force hard reload manually on the client side(on Chrome ctrl>f5). Is there a way to not have to do this manually in React?

I've noticed some posts about setting a query string param with a versioning system, and many solutions for angular CLI, but nothing on React.

Could someone please help me how to achieve this goal

Upvotes: 2

Views: 2591

Answers (1)

winwiz1
winwiz1

Reputation: 3164

The output of a React application build are .html file(s) that are usually rather small and script bundles which can be quite large. This goal can be achieved without any performance or loading time penalty by telling the browser not to cache .html files and cache bundles.

You need to ensure that the name of each bundle contains some hash unique for each build. This can be done automatically as a part of the build.

Upvotes: 3

Related Questions