Differences in cachebuster implementations

2019-09-10 07:47发布

"Implementation" might be an awful strong word, but I wrote some "code" to do cachebusting for a javascript ad serving implementation.

I did it with what I presumed was the shortest and most obvious method:

var cachebuster=Date.now();

And then append that to the .js query string. I got an e-mail from the ad vendor stating that all script requests had to now include this bit of code:

var cachebuster=Math.round(Math.random() * 100000);

Presumably the vendor doesn't know we were already doing our own and it was just a form letter. However I wanted to make sure I wasn't missing something. This seems like a much dumber implementation (you have a chance of a random number coming up twice and therefore getting a cached script, plus it's longer and slower*), but it came from the vendor who presumably knows what they're doing. Any reason to go their route, instead of mine?

*albeit imperceptibly

0条回答
登录 后发表回答