Static files are cached and loading from service worker
When I do any changes in my CSS file and do a build, a new CSS bundle file is created.
Build One

Console.log of Build One

Build Two

Console.log of Build Two

If you see in the second build the CSS file name is changed from main.1012bf29.chunk.css to main.2ff4e3dd.chunk.css
But if you see the console log for both the build is same, the CSS file of the first build is cached.
Expected output: On every build, the cache needs to be cleared.
Note: I have enabled PWA in my react app. React version is 16.7.0, I have created my project using the create-react-app command
This isn't a bug I don't think. Read this section from the docs for details on why you're probably seeing this.
I think the index.html file is cached and even after so many changes, I took a build, even then the old CSS files are getting loaded. If I do a hard refresh or clearing the cache it is working. How can I solve this problem?
From the documentation I linked:
After the initial caching is done, the service worker lifecycle controls when updated content ends up being shown to users. This means that users will end up seeing older content until they close (reloading is not enough) their existing, open tabs. See this blog post for more details about this behavior.
So it's expected that it wont update until all tabs are closed. I personally disable service worker support because it's difficult to debug and understand. You can still make use of caching via your webserver without using any of the included PWA stuff.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.