views:

23

answers:

3

such as

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

the ?1287492558

and with it i cant load the thing with question marks and numbers. And i can load it as soon as i deleted the thing. So as the style sheet that i load dynamically using eRB.

I also discover that

  • i would able to load the image for the first time , 3rd time , 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 image using different ?number , it can be load. But with same ?number "Internal Server Error private method `gsub!' called for # " show

So , can any rails guru please tell me what is the purpose of ?1287492558 and how to delete it or how to make rails load the image url?

+1  A: 

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.

Anatoly G
But the rails server seem not to generate a new resource ... what might be the possible reason? I am using ubuntu with Rails 2.2.3
wizztjh
how do you know it's not generating a new resource? This request would be fulfilled by the static content server, not the dynamic rails (unless you mapped /images to go through the rails processor)
Anatoly G
because the ?1287492558 is always the same every time i refresh. That is what i mean by resources. Sorry to confuse you. And thanks for helping me out
wizztjh
weird. this might be an artifact of some startup process. I am not an expert on rails - maybe Jacob Relkin (below) can help
Anatoly G
because if the purpose of prevent caching , then the ?number should be different every time , but i have found out it is the same every time i load . So i think the problem is the same number every time?
wizztjh
Ohh , thanks for helping anyway , appreciate it.
wizztjh
+1  A: 

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.

Faisal
Thanks , but from what i see from the documentation stylesheet_link_tag "style" # => <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />seems that no ?number will be generated
wizztjh
maybe i am in development state ?
wizztjh
probably. because in dev mode, no caching is active by default
Faisal
A: 

I have solve it with using mongrel .... so for you guys that see this post ... dont use WeBrick

wizztjh