开发者

Link created by eRuby have the same? number every time I refresh

The link created by eRuby have the same? number every time I refresh.

Such as

<img alt="Auto" class="list-image" src="/images/auto.jpg?1287492558" />

the ?1287492558

And with it I can't load the thing with question marks and numbers. And I can load it as soon as I delete the thing. So as the style sheet that I load dynamically using eRuby.

I also discovered that

  • I would able to load the image for the first time, the 3rd time, the 6th time and so on.
  • And load my stylesheet for the first time only. Not after refresh.
  • the ?number is always the same every time I refresh
  • when I request the link of an image using different ?number, it can be loaded. But with the same ?number "Internal Server Error private method `gsub!' called for #" shows.

So, what is the purpose of ?1287492558 and how to delete it or how t开发者_如何学Goo make Ruby on Rails load the image URL?


don't know how to delete it, but the purpose of it is to avoid the browser from caching this image. It's a trick used forever - adding a timestamp to a resource to make it look like a new resource, and thus not use the cached version.


Opposite to what Anatoly and Jacob said, this number is used so that the browser WILL cache the static content. The number you see is the timestamp of last update on that file. So the number will remain the same, and your browser can cache that content, until the content is changed, so the last update time changes, and this causes all browsers to refresh the file in their caches. I don't know how to disable it, will check the docs and report back if I find anything.


I have solved it with using Mongrel. Don't use WEBrick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜