Jump to content

AssetLoader : how to force to load an asset and not what is in cache ?


bali33
 Share

Recommended Posts

Hi guys,

 

I'm looking for a way to be sure that my assets are correctly loaded when my project is updated. I'd like to be able to add a variable at the end of the asset path like myAssetPath/myAsset.png?v=1.1 but it seems to not work.

 

How can I achieve that ?

 

Thank you

Link to comment
Share on other sites

Same result which is logic because there is no difference between myAssetPath/myAsset.png?v=1.1 and 'myAssetPath/myAsset.png?'+Date.now in both cases a a value is added to the asset path - and that value added to the path triggers an error : Uncaught TypeError: Cannot read property 'baseTexture' of undefined 

Link to comment
Share on other sites

actually there is a huge difference between the two. Though my code was slightly off (fixed it) 

'myAssetPath/myAsset.png?'+Date.now(); 

When the browsers get a request for myAssetPath/myAsset.png?v=1.1 and you make the request a second or third time, it will pull in the cached version. My code generates a new number each time you make the request thus preventing the cache from ever kicking in. You could even use Math.random() but you run the slight risk that the number will repeat.

Link to comment
Share on other sites

Hi,

 

My code was just an example to explain that the structure path + variable returns an error, the one I pasted in my previous post. That's why I said there was no differences between the two, because they have both the same structure : path + variable. 

 

Thanks for your help. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...