English 中文(简体)
为什么如此之多的 Java字把随机数字用在什么东西? 串通?
原标题:Why do so many Javascript scripts append random numbers to things? Collision?

我是最近学到的贾瓦文,我曾看到一些实例(Facebook.com,阅读能力书记册),这些实例利用Math.rand()进行连接。

这个问题如何解决? 可读书记册的一个实例参数:

_readability_script.src= http://lab.arc90.com/....script.js?x= +(Math.random());

是否在贾瓦伦有碰撞,或者说这种碰撞正在打破?

最佳回答

正如Rubens所说,这通常是一种防止ach割的骗子。 浏览器通常会非常积极地 c和CSS,这可以拯救你带宽,但在改变你的文字时也会造成部署问题。

想法是浏览器将考虑以下网址的资源:http://www.example.com/something.js?foo的不同之处在于,因此获得利用当地海滩检索资源。

较常见的情况是,每当资源需要改变时,就可调整增益值。 这样,你就受益,重复了客户方的要求,但在部署新版本时,你可以强迫浏览器浏览新版本。

从个人角度来说,我要把档案的最后经过修改的时间视为一个不完美的时局,因此,我不必在我改变档案时打猎和抽水。

问题回答

主要要点是避免浪费这些资源。

这将确保文字是独一无二的,不会因为每次出现争.变化而成为固定的资源。

这是因为互联网探索者喜欢收集一切东西,包括通过 Java本书发出的要求。

另一种方式是,在《欧洲刑法》中没有随机编号的情况下,将Cache-Control的头盔添加到目录上,并附上你不想要的物品:

# .htaccess
Header set Cache-Control "no-cache"
Header set Pragma "no-cache"

大多数浏览器尊重Cache-Control,但IE(包括7,n t 测试8)只承认Pragma头盔。

视浏览器选择如何解释资源背面,如果你只是要求浏览器将ur改到以前使用的ur,那么你可能不会产生预期的效果。 (大多数变压图像纽扣吨依赖浏览器将重新使用热量资源的速度)

当你想确保浏览器获得资源的新复制件(如动态的存量图象或类似)时,你迫使浏览器总是想到的是,通过评估日期/时间或每升数或随机加贝,内容是新的。

有一个叫作qui的工具,可以浏览网页。 使用随机编号将保证这种请求不会由类似中间商提出。 即便是用头盔定着Cache-Control“no-cache”,你仍可能需要增加随机数目,以通过“默许”等内容。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.