Jatinder Singh
2006-Oct-25 03:18 UTC
Browser caching creating problems while updating an image on browser using Ajax
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, <div id="image_place_holder"> <img src=''/pictures/1/some_week.jpg''> </div> 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 ="<img src=''/pictures/#{session[:user_id]}/#{@picName}''>" 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Vishnu Gopal
2006-Oct-25 18:05 UTC
Re: Browser caching creating problems while updating an image on browser using Ajax
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 <img src="/pictures/1/some_week.jpg?<%= Time.now %>" /> The first is more elegant in that it tracks date modified time of the file to generate the asset timestamp. Later, Vish On 10/25/06, Jatinder Singh <jatinder.saundh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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, > <div id="image_place_holder"> > <img src=''/pictures/1/some_week.jpg''> > </div> > > 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 ="<img src=''/pictures/#{session[:user_id]}/#{@picName}''>" > 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 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jatinder Singh
2006-Oct-25 18:32 UTC
Re: Browser caching creating problems while updating an image on browser using Ajax
Thanks Vishnu, now it works! Regards, Jatinder On 10/25/06, Vishnu Gopal <g.vishnu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > <img src="/pictures/1/some_week.jpg?<%= Time.now %>" /> > > The first is more elegant in that it tracks date modified time of the file > to generate the asset timestamp. > > Later, > Vish > > On 10/25/06, Jatinder Singh <jatinder.saundh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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, > > <div id="image_place_holder"> > > <img src=''/pictures/1/some_week.jpg''> > > </div> > > > > 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 ="<img src=''/pictures/#{session[:user_id]}/#{@picName}''>" > > 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 > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---