Note that there are some explanatory texts on larger screens.

plurals
  1. POCaching problem with asynchronous javascript loading with onload event
    primarykey
    data
    text
    <p>I am currently trying to load some js files asynchronously, so that they are not able to block the rest of the website. I mainly followed the descriptions found here: </p> <p><a href="http://friendlybit.com/js/lazy-loading-asyncronous-javascript/" rel="nofollow noreferrer">Asynchronous Javascript</a></p> <p>In terms of the non blocking loading of the javascript file this works great, but i got now the problem that the javascript file is cached and stays cached even if i change the content (also doing shift-reload does not help anything).</p> <p>My current code of loading the script looks like the following:</p> <pre><code> (function() { function xx_async_load() { var xx = document.createElement('script'); xx.type = 'text/javascript'; xx.async = true; xx.src = 'http://myserver.de/myjs.js'; var el = document.getElementsByTagName('script')[0]; el.parentNode.insertBefore(xx, el); } if (window.addEventListener) { window.addEventListener('load', xx_async_load, false); } else if (window.attachEvent){ window.attachEvent('onload', xx_async_load); } })(); </code></pre> <p>If i call the code inside "xx_async_load" directly and change the myjs.js, the changes are getting recognized, but if I am loading this through the onload event it always stays cached and the changed are never recognized.</p> <p>Does anybody know a solution how I make the browser to recognize the changes in the cached files (problem appears in Opera, FF and IE work fine)?</p> <p><strong>EDIT:</strong> If i look at the "Network" tab of Operas Dragonfly, there isn't even a request done on reload for the cached JS file, it seems that it is directly loading it from cache without even checking against the file on the server.</p> <p><strong>EDIT2:</strong> I will test how long it stays in the cache. If its gone till tomorrow its fine. Else I can still propose the workaround with a date param (so accepting that answer). Thx again.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload