bali33 Posted October 31, 2014 Share Posted October 31, 2014 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 Quote Link to comment Share on other sites More sharing options...
ericjbasti Posted November 1, 2014 Share Posted November 1, 2014 Use 'myAssetPath/myAsset.png?'+Date.now() Quote Link to comment Share on other sites More sharing options...
bali33 Posted November 3, 2014 Author Share Posted November 3, 2014 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 Quote Link to comment Share on other sites More sharing options...
ericjbasti Posted November 4, 2014 Share Posted November 4, 2014 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. Quote Link to comment Share on other sites More sharing options...
bali33 Posted November 4, 2014 Author Share Posted November 4, 2014 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. Quote Link to comment Share on other sites More sharing options...
wayfinder Posted November 4, 2014 Share Posted November 4, 2014 If it's just for dev purposes, you can disable the cache while the dev panel is open in chrome (settings) Quote Link to comment Share on other sites More sharing options...
ericjbasti Posted November 5, 2014 Share Posted November 5, 2014 @bali33 I've done exactly what you're hoping to do for years by adding in a randomized variable to the url path of a file. http://jsbin.com/tokiqoxipu/1/ Image loaded with a variable... no error. just an image the browser doesn't think its seen before so it fired a new request. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.