Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Technical question about assets
- Zro716
-
1000+ posts
Technical question about assets
As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?
But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.
Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.
But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.
Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.
- Dylan5797
-
1000+ posts
Technical question about assets
I am sure I can, I have a lot of experience uploading and experimenting with this API. As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?
But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.
Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.
As far as I know, assets remain there forever even if all the projects containing them are deleted–an algorithm would have to scan all the projects for asset cleanup, it would cause a degrade of performance on the site whenever someone deleted a project.
Also you can't upload a new version of an existing asset with the same hash if it already exists.
- MegaApuTurkUltra
-
1000+ posts
Technical question about assets
I can upload assets that aren't tied to a project and they stay
- -Radical-
-
500+ posts
Technical question about assets
Does that mean they don't stay if they are tied to a project? I can upload assets that aren't tied to a project and they stay
(Sorry for asking dumb questions, I'm only 13)
- MathWizz
-
100+ posts
Technical question about assets
I am pretty confident they stay forever. I don't think going though millions of assets and checking that they are present in a single project's JSON out of millions is practical.
- -Radical-
-
500+ posts
Technical question about assets
I guess so. Just keep in mind that every single costume, background, or sound file counts as 1 asset. And there's even a URL for it!
So, guess what. Scratch is now a web host!
JK, that would be kinda mean.
So, guess what. Scratch is now a web host!
JK, that would be kinda mean.
- novice27b
-
1000+ posts
Technical question about assets
Yeah, you can do some interesting things with the CDN API. There is a file size limit however, so you couldn't really use it for anything serious. I guess so. Just keep in mind that every single costume, background, or sound file counts as 1 asset. And there's even a URL for it!
So, guess what. Scratch is now a web host!
JK, that would be kinda mean.
It made a security vulnerability in the scratch site possible (https://scratch-mit-edu.ezproxyberklee.flo.org/discuss/topic/178044/ ) and it also means you can do tricks like this: https://scratch-mit-edu.ezproxyberklee.flo.org/discuss/topic/179047/ (generating hash collisions).
Last edited by novice27b (May 19, 2016 21:47:35)
- comp09
-
1000+ posts
Technical question about assets
Speaking of uploading assets to the CDN, has anyone gotten MP3s or PCM (not ADPCM) WAVs to properly play in a Scratch project? It seems older projects have some sounds encoded with PCM instead of the lower quality ADPCM.
- MegaApuTurkUltra
-
1000+ posts
Technical question about assets
I've put MP3s on the cdn for my high quality sound extension to play Speaking of uploading assets to the CDN, has anyone gotten MP3s or PCM (not ADPCM) WAVs to properly play in a Scratch project? It seems older projects have some sounds encoded with PCM instead of the lower quality ADPCM.

Last edited by MegaApuTurkUltra (May 20, 2016 02:49:30)
- thisandagain
-
500+ posts
Technical question about assets
As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?
But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.
Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.
Assets stay on the server forever even if the associated project is deleted (or as some have mentioned you can even do crazy things like upload assets without a project … which is less than awesome). This has some advantages in terms of limiting the amount of CPU and DB utilization that we need to track assets but does take up a significant amount of disk space (think terabytes rather than gigabytes). @codubee and I are doing some work on the projects and assets systems next month and may be rethinking how this works.
- Zro716
-
1000+ posts
Technical question about assets
Excellent responses, everyone. So my fear of nothing ever being permanently deleted is confirmed, and furthermore, thisandagain shows up telling us that a reconsideration of the CDN is a possibility soon. I should probably close this topic now that it has been resolved. Thanks!
- Discussion Forums
- » Advanced Topics
-
» Technical question about assets