Differences in cachebuster implementations

限于喜欢 提交于 2019-12-25 08:19:15

问题


"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

来源:https://stackoverflow.com/questions/22665311/differences-in-cachebuster-implementations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!