Does Chrome not recognize my changes in my javascript file and load old code?

I have been sitting here for almost an hour here to test the site I am creating. Since I wanted to see new changes from my code, which I reloaded, but it reloaded the old one. I opened devetools to hard reboot and reboot the hard drive, they load my old code. I went into incognito mode and he did the same. I again went to devtools to disable the cache from the settings and checked to disable the cache on the network tab; it still caches my old code. Add-ons for clearing the cache did not work either. Man, I haven't had this problem before, and it only happened last night, and today is the worst.

I am so lost because chrome does not load my new changes from my javascript file. Is there a solution for this?

+4
source share
4 answers

One solution to this problem is to force a resource reload to avoid caching. You can get this URL change with http get parameters:

Edit:

<script src="myscripts.js"></script>

at

<script src="myscripts.js?newversion"></script>

If newversion can be any string, as it will be ignored. A useful option is to use the date or version of your code.

I found this workaround to be especially useful when I ran into this problem and wanted all clients (and not just my own browser!) To run a new version of the code.

+6
source

- (, gulp grunt)? , , .

@airos . JS ( URL-).

+1

, :

PHP, JavaScript URI .

<script src="js/my-script.js?<?php echo filemtime('js/my-script.js'); ?>"> 
</script>

:

<script src="js/my-script.js?1524155368"></script>

URI , .

, - , .

0

.

-5

Source: https://habr.com/ru/post/1671819/


All Articles