# Browser caching creating problems while updating an image on

**URL:** <https://www.ruby-forum.com/t/browser-caching-creating-problems-while-updating-an-image-on/73544>\
**Category:** Rails\
**Created:** [October 25, 2006, 5:19am UTC](https://www.ruby-forum.com/t/browser-caching-creating-problems-while-updating-an-image-on/73544 "2006-10-25T05:19:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [October 25, 2006, 5:19am UTC](https://www.ruby-forum.com/t/browser-caching-creating-problems-while-updating-an-image-on/73544/1 "2006-10-25T05:19:28Z")

</div>

Hi,

On one of the views I display an image “some\_week.jpg”, which basically  
displays a graph for data corresponding to a particular week, by default  
current week.  
Following is the code snippet in view which displays an image,

 ![](https://www.ruby-forum.com/pictures/1/some_week.jpg)

On this view, User has an option of selecting some other week and see  
the  
graph corresponding to it. I have implemented this using an AJAX call  
where  
the graph image is constucted using Gruff library on server side and  
following response is sent back from RJS,  
imageTag =" ![](https://www.ruby-forum.com/pictures/#%7Bsession%5B:user_id%5D%7D/#%7B@picName%7D)"  
page.replace\_html ,“image\_place\_holder”, imageTag

where, session[:user\_id] =1 and @picName = “some\_week.jpg”

After the response the image in the browser is still the old image, I  
verified on server, the new image is created in the mentioned directory  
but  
browser seem to cache the old image.

I am using Mozilla Firefox 1.5.0.7.

Help is appreciated.

Regards,

Jatinder

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [October 25, 2006, 8:08pm UTC](https://www.ruby-forum.com/t/browser-caching-creating-problems-while-updating-an-image-on/73544/2 "2006-10-25T20:08:24Z")

</div>

Timestamp the image.

image\_tag should do this automatically (if you put your image in  
public/images):

image\_tag('some\_week.jpg") or you can do  
 ![](https://www.ruby-forum.com/pictures/1/some_week.jpg?<%=%20Time.now%20%>)

The first is more elegant in that it tracks date modified time of the  
file  
to generate the asset timestamp.

Later,  
Vish

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [October 25, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/browser-caching-creating-problems-while-updating-an-image-on/73544/3 "2006-10-25T21:32:38Z")

</div>

Thanks Vishnu, now it works!

Regards,  
Jatinder
