Closed BYK closed 7 years ago
👀
I just looked through your source code, since normally nothing should go wrong with content addressable hashing. I think I saw something that might explain why the hashing might be off some times.
Your tree traversal algorithm is a loop sorted ascending by incoming relations length. This is along the right lines, but still leaves room for error in ordering. The correct algorithm to traverse the tree is starting at the entry points, usually HTML, and do a depth first post-order traversal. This gives you a guarantee of having hashed all children before any of their containing parents.
I think such a change might completely remove the need for a cache buster option like this one.
Here is our traversal algorithm in assetgraph for reference: https://github.com/assetgraph/assetgraph/blob/master/lib/index.js#L520-L537
@Munter we are doing a depth-first post-order. I think our tanglement with Grunt and allowing multiple entry points masks that.
The reason we need a cache busting system like this is because recently CloudFlare messed some of our PNG images and since they almost never change, we need to invalidate the hashses to break infinite caching.
Oh dear... Never mind me then :)
This allows mass changing hashes when something goes wrong.