Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome sometimes caching webpack://scripts wierdly

I use webpack as a module bundler

I have map files enabled

In chrome my original script files come from a special webpack resource enter image description here

I'm not too sure what causes it but sometimes an old version of a script gets cached. The actual new code is still updating correctly but the version referenced by the map is out of date. This means line numbers don't match anymore and I cant see any code changes (eg super annoying).

It seems to eventually just fix itself but makes me sad in the meantime.

Has anyone else had similar issues/have any ideas of how to sort it out?

It seems to be isolated to chrome (if I go to another browser the correct version is loaded)

I have tried:

  • Deleting the map file and regening it
  • Empty cache and hard reload
  • Manually navigating to the file in chrome (correct version is returned but it remains out of date when refed by map file)
like image 883
Not loved Avatar asked Sep 15 '15 22:09

Not loved


People also ask

Why is Google Chrome loading old Web pages and not the updated ones?

The problem is that Chrome needs to have must-revalidate in the Cache-Control` header in order to re-check files to see if they need to be re-fetched. This tells Chrome to check with the server, and see if there is a newer file. If there is a newer file, it will receive it in the response.


1 Answers

I worked out that this was caused by the actual map file being cached.

If you open the map file in a new tab and hard reload it, the source is all updated correctly

Its probably a bug in chrome that this is not reloaded with the dev tools disable cache setting or the pages hard reload.

like image 120
Not loved Avatar answered Sep 28 '22 03:09

Not loved